From 7ea8a7d45fee82fd4ba74a067796f189b86dbcfc Mon Sep 17 00:00:00 2001 From: pagedown Date: Sat, 15 Jan 2022 18:38:05 +0800 Subject: [PATCH] Fix searching the last command output --- kitty/screen.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index 442ad79d0..126c3381a 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2756,12 +2756,14 @@ cmd_output(Screen *self, PyObject *args) { switch (which) { case 0: // last run cmd - found = find_cmd_output(self, &oo, self->cursor->y, self->scrolled_by, -1, false); + // When scrolled, the starting point of the search for the last command output + // is actually out of the screen, so add the number of scrolled lines + found = find_cmd_output(self, &oo, self->cursor->y + self->scrolled_by, self->scrolled_by, -1, false); break; case 1: // first on screen found = find_cmd_output(self, &oo, 0, self->scrolled_by, 1, true); break; - case 2: // last visited cmd + case 2: // last visited cmd if (self->last_visited_prompt.scrolled_by <= self->historybuf->count && self->last_visited_prompt.is_set) { found = find_cmd_output(self, &oo, self->last_visited_prompt.y, self->last_visited_prompt.scrolled_by, 0, false); } break;