Track cursor position explicitly during rewrap

Instead of using heuristics to position the cursor after a resize, track
the position during re-wrapping and place the cursor at the re-wrapped
position. Fixes #242 (I hope)
This commit is contained in:
Kovid Goyal
2018-02-02 12:05:52 +05:30
parent 4c53a74fa9
commit 2ee9844c2b
6 changed files with 43 additions and 34 deletions

View File

@@ -217,13 +217,13 @@ class TestScreen(BaseTest):
s = self.create_screen(scrollback=6)
s.draw(''.join([str(i) * s.columns for i in range(s.lines)]))
s.resize(3, 10)
self.ae(str(s.line(0)), '2'*5 + '3'*5)
self.ae(str(s.line(1)), '4'*5)
self.ae(str(s.line(2)), ''*5)
self.ae(str(s.line(0)), '0'*5 + '1'*5)
self.ae(str(s.line(1)), '2'*5 + '3'*5)
self.ae(str(s.line(2)), '4'*5)
s.resize(5, 1)
self.ae(str(s.line(0)), '4')
hb = s.historybuf
self.ae(str(hb), '4\n3\n3\n3\n3\n3')
self.ae(str(hb), '3\n3\n3\n3\n3\n2')
s = self.create_screen(scrollback=20)
s.draw(''.join(str(i) * s.columns for i in range(s.lines*2)))
self.ae(str(s.linebuf), '55555\n66666\n77777\n88888\n99999')