term: reverse scroll: free scrolled out lines

This ensures *everything* in the circular scrollback history, after
the bottom of the screen, is either NULL rows, or belong to the
scrollback *history* (as opposed to the future history).

This fixes an issue when calculating the scrollback start, which for
example would trigger a crash when moving the viewport (i.e. scrolling
with the mouse, or PgUp/PgDown).

Closes #1190
This commit is contained in:
Daniel Eklöf 2022-10-14 18:00:48 +02:00
parent 43a48f53d4
commit 3d9a429499
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -2676,6 +2676,18 @@ term_scroll_reverse_partial(struct terminal *term,
selection_scroll_down(term, rows);
}
/* Unallocate scrolled out lines */
for (int r = region.end - rows; r < region.end; r++) {
const int abs_r = grid_row_absolute(term->grid, r);
struct row *row = term->grid->rows[abs_r];
grid_row_free(row);
term->grid->rows[abs_r] = NULL;
if (term->render.last_cursor.row == row)
term->render.last_cursor.row = NULL;
}
sixel_scroll_down(term, rows);
bool view_follows = term->grid->view == term->grid->offset;