url-mode: dirty the “last cursor” cell before taking the snapshot

This ensures the “last cursor” cell is re-drawn (without a cursor, if
the cursor has moved), both in the snapshot:ed grid, and later, when
we switch back to the real grid.

We must also be careful and reset term->render.last_cursor.row
both when *entering* and *leaving* URL mode, to ensure it doesn’t
point to an invalid row.
This commit is contained in:
Daniel Eklöf 2021-02-23 09:24:50 +01:00
parent aa10cd54ea
commit bc71e06d5f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -637,6 +637,17 @@ urls_render(struct terminal *term)
tag_cells_for_url(term, &it->item, true);
}
/* Dirty the last cursor, to ensure it is erased */
{
struct row *cursor_row = term->render.last_cursor.row;
if (cursor_row != NULL) {
struct cell *cell = &cursor_row->cells[term->render.last_cursor.col];
cell->attrs.clean = 0;
cursor_row->dirty = true;
}
}
term->render.last_cursor.row = NULL;
/* Snapshot the current grid */
term->url_grid_snapshot = grid_snapshot(term->grid);
@ -662,6 +673,15 @@ urls_reset(struct terminal *term)
grid_free(term->url_grid_snapshot);
free(term->url_grid_snapshot);
term->url_grid_snapshot = NULL;
/*
* Make sure last cursor doesnt point to a row in the just
* free:d snapshot grid.
*
* Note that it will still be erased properly (if hasnt already),
* since we marked the cell as dirty *before* taking the grid
* snapshot.
*/
term->render.last_cursor.row = NULL;
if (term->window != NULL) {