Add test for multiline prompt jumping

This commit is contained in:
Kovid Goyal 2021-07-13 12:18:48 +05:30
parent 3b8da7e4c2
commit bd5f100f13
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 1 deletions

View File

@ -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;

View File

@ -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')