From bd5f100f1303e71e6de33cbd3f81531749ae0f82 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 13 Jul 2021 12:18:48 +0530 Subject: [PATCH] Add test for multiline prompt jumping --- kitty/screen.c | 2 +- kitty_tests/screen.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kitty/screen.c b/kitty/screen.c index ca14de667..769ec52e4 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1741,7 +1741,7 @@ screen_history_scroll_to_prompt(Screen *self, int num_of_prompts_to_jump) { if (range_line_(self, y)->is_prompt_start) num_of_prompts_to_jump--; } if (delta < 0) { - while (-y + 1 < (int)self->historybuf->count && range_line_(self, y - 1)->is_prompt_start) y--; + while (-y + 1 <= (int)self->historybuf->count && range_line_(self, y - 1)->is_prompt_start) y--; } unsigned int old = self->scrolled_by; self->scrolled_by = y >= 0 ? 0 : -y; diff --git a/kitty_tests/screen.py b/kitty_tests/screen.py index 5b807616b..c84606bb9 100644 --- a/kitty_tests/screen.py +++ b/kitty_tests/screen.py @@ -935,3 +935,13 @@ class TestScreen(BaseTest): self.assertTrue(s.scroll_to_prompt(1)) self.ae(str(s.visual_line(0)), '$ 2') self.assertFalse(s.scroll_to_prompt(1)) + + s = self.create_screen() + mark_prompt(), s.draw('$ 0') + s.carriage_return(), s.index() + mark_prompt(), s.draw('$ 1') + for i in range(s.lines): + s.carriage_return(), s.index() + s.draw(str(i)) + self.assertTrue(s.scroll_to_prompt()) + self.ae(str(s.visual_line(0)), '$ 0')