From e23d6877c0e9121a5c60706dbc1dc125c4ff97e6 Mon Sep 17 00:00:00 2001 From: Arvin Verain Date: Mon, 17 Feb 2025 09:33:29 +0800 Subject: [PATCH] fix: Page cmd outputs properly regardless of amount of prompt lines Also skip fetching lines of wrapped prompts --- kitty/screen.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index 5d8658847..817abefec 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -4078,7 +4078,7 @@ find_cmd_output(Screen *self, OutputOffset *oo, index_type start_screen_y, unsig } else if (line && line->attrs.prompt_kind == OUTPUT_START && !range_line_is_continued(self, y1)) { found_output = true; start = y1; found_prompt = true; - // keep finding the first output start upwards + direction = 1; } y1--; y2++; } @@ -4091,22 +4091,21 @@ find_cmd_output(Screen *self, OutputOffset *oo, index_type start_screen_y, unsig line = checked_range_line(self, y1); if (line && line->attrs.prompt_kind == PROMPT_START && !range_line_is_continued(self, y1)) { if (direction == 0) { - // find around: stop at prompt start - start = y1 + 1; + found_prompt = true; break; } found_next_prompt = true; end = y1; } else if (line && line->attrs.prompt_kind == OUTPUT_START && !range_line_is_continued(self, y1)) { - start = y1; + found_output = true; start = y1; + found_prompt = true; break; } y1--; } if (y1 < upward_limit) { oo->reached_upper_limit = true; - start = upward_limit; + found_output = true; start = upward_limit; } - found_output = true; found_prompt = true; } // find downwards @@ -4116,11 +4115,16 @@ find_cmd_output(Screen *self, OutputOffset *oo, index_type start_screen_y, unsig line = checked_range_line(self, y2); if (line && line->attrs.prompt_kind == PROMPT_START) { if (!found_prompt) found_prompt = true; - else if (found_output && !found_next_prompt) { + else if (found_prompt && !found_output) { + // skip fetching wrapped prompt lines + while (range_line_is_continued(self, y2)) { + y2++; + } + } else if (found_output && !found_next_prompt) { found_next_prompt = true; end = y2; break; } - } else if (line && line->attrs.prompt_kind == OUTPUT_START && found_prompt && !found_output) { + } else if (line && line->attrs.prompt_kind == OUTPUT_START && !found_output) { found_output = true; start = y2; } y2++;