From f0d2d01a36337aa84c219f792f5174971aa6242e Mon Sep 17 00:00:00 2001 From: pagedown Date: Sun, 16 Jan 2022 04:02:13 +0800 Subject: [PATCH] Fix calculating the end of the command output --- kitty/screen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index 8b874638f..6de09427f 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2668,10 +2668,10 @@ get_line_from_offset(void *x, int y) { } static bool -find_cmd_output(Screen *self, OutputOffset *oo, index_type start_y, unsigned int scrolled_by, int direction, bool on_screen_only) { +find_cmd_output(Screen *self, OutputOffset *oo, index_type start_screen_y, unsigned int scrolled_by, int direction, bool on_screen_only) { bool found_prompt = false, found_output = false, found_next_prompt = false; int start = 0, end = 0; - int y1 = start_y - scrolled_by, y2 = y1; + int init_y = start_screen_y - scrolled_by, y1 = init_y, y2 = init_y; const int upward_limit = -self->historybuf->count; const int downward_limit = self->lines - 1; const int screen_limit = -scrolled_by + downward_limit; @@ -2736,7 +2736,7 @@ find_cmd_output(Screen *self, OutputOffset *oo, index_type start_y, unsigned int if (found_next_prompt) { oo->num_lines = end >= start ? end - start : 0; } else if (found_output) { - end = direction < 0 ? start_y : (unsigned int)downward_limit; + end = direction < 0 ? init_y : downward_limit; oo->num_lines = end >= start ? end - start : 0; } else return false; oo->start = start;