From bc71e06d5f5b9f27aca373e523627c70670e979c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 23 Feb 2021 09:24:50 +0100 Subject: [PATCH] =?UTF-8?q?url-mode:=20dirty=20the=20=E2=80=9Clast=20curso?= =?UTF-8?q?r=E2=80=9D=20cell=20before=20taking=20the=20snapshot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- url-mode.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/url-mode.c b/url-mode.c index 8b1b9795..54edc524 100644 --- a/url-mode.c +++ b/url-mode.c @@ -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” doesn’t point to a row in the just + * free:d snapshot grid. + * + * Note that it will still be erased properly (if hasn’t already), + * since we marked the cell as dirty *before* taking the grid + * snapshot. + */ term->render.last_cursor.row = NULL; if (term->window != NULL) {