From ccafdacc6fecd653827e6985a4ce016409e16946 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 18 Mar 2021 10:36:33 +0530 Subject: [PATCH] Ensure cursor position is correct when filling line buffer --- kitty/screen.c | 1 + kitty_tests/screen.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/kitty/screen.c b/kitty/screen.c index 473e34b7c..094cdbcfe 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -330,6 +330,7 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) { if (!historybuf_pop_line(self->historybuf, self->alt_linebuf->line)) break; INDEX_DOWN; linebuf_copy_line_to(self->main_linebuf, self->alt_linebuf->line, 0); + self->cursor->y++; } } return true; diff --git a/kitty_tests/screen.py b/kitty_tests/screen.py index 594da05cb..9784dad83 100644 --- a/kitty_tests/screen.py +++ b/kitty_tests/screen.py @@ -318,8 +318,10 @@ class TestScreen(BaseTest): # Height increased, width unchanged → pull down lines to fill new space at the top s = prepare_screen(map(str, range(6))) assert_lines('2', '3', '4', '5', '') + dist_from_bottom = s.lines - s.cursor.y s.resize(7, s.columns) assert_lines('0', '1', '2', '3', '4', '5', '') + self.ae(dist_from_bottom, s.lines - s.cursor.y) # Height increased, width increased → rewrap, pull down s = prepare_screen(['0', '1', '2', '3' * 15])