Fix searching the last command output

This commit is contained in:
pagedown 2022-01-15 18:38:05 +08:00
parent b32edf54f8
commit 7ea8a7d45f
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -2756,12 +2756,14 @@ cmd_output(Screen *self, PyObject *args) {
switch (which) { switch (which) {
case 0: // last run cmd 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; break;
case 1: // first on screen case 1: // first on screen
found = find_cmd_output(self, &oo, 0, self->scrolled_by, 1, true); found = find_cmd_output(self, &oo, 0, self->scrolled_by, 1, true);
break; 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) { 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); found = find_cmd_output(self, &oo, self->last_visited_prompt.y, self->last_visited_prompt.scrolled_by, 0, false);
} break; } break;