Fix off by one when restoring cursor position after resize. Fixes #344

This commit is contained in:
Kovid Goyal 2018-02-25 09:15:48 +05:30
parent 11e85ac703
commit 1fe936dbbc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 1 deletions

View File

@ -70,7 +70,7 @@ rewrap_inner(BufType *src, BufType *dest, const index_type src_limit, HistoryBuf
copy_range(src->line, src_x, dest->line, dest_x, num);
if (is_tracked_line && src_x <= *track_x && *track_x < src_x + num) {
*track_y = dest_y;
*track_x = dest_x + (*track_x - src_x);
*track_x = dest_x + (*track_x - src_x + 1);
}
src_x += num; dest_x += num;
}

View File

@ -245,6 +245,12 @@ class TestScreen(BaseTest):
y = s.cursor.y
self.assertIn('|', str(s.line(y)))
s = self.create_screen()
draw('a')
x_before = s.cursor.x
s.resize(s.lines - 1, s.columns)
self.ae(x_before, s.cursor.x)
def test_tab_stops(self):
# Taken from vttest/main.c
s = self.create_screen(cols=80, lines=2)