diff options
| author | CismonX <admin@cismon.net> | 2026-07-29 00:25:40 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2026-07-30 05:37:16 +0000 |
| commit | 56d15238d1a61a539171667e5713cd6939c08d07 (patch) | |
| tree | a0d63dbf32e965d464f7af7c931634f9fbe74671 | |
| parent | selection: find-quote-right: assert next-row > 0 (diff) | |
render: fix broken selection on delayed resize
Interactive resize of a terminal window breaks current selection,
if scrollback is not empty, and option 'resize-delay-ms' is not 0.
This behavior is introduced by commit 296e75f4f5, which:
- Subtracts selection row by view offset every time render_resize()
is called, resulting in bad coordinates.
- Does not properly restore the original selection coordinates
during the final text reflow stage.
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | render.c | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa2fc0e..9cda7c50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -130,6 +130,7 @@ where libc doesn't include it (e.g. Termux + Android API < 29). * Crash in `select-quote` when the right-side quote appeared right after a newline, in column 0 ([#2405][2405]). +* Resizing a terminal window may break current selection. [2353]: https://codeberg.org/dnkl/foot/issues/2353 [2352]: https://codeberg.org/dnkl/foot/issues/2352 @@ -4382,6 +4382,9 @@ delayed_reflow_of_normal_grid(struct terminal *term) xassert(term->interactive_resizing.new_rows > 0); + if (term->grid == &term->normal) + term->selection.coords = term->interactive_resizing.selection_coords; + struct coord *const tracking_points[] = { &term->selection.coords.start, &term->selection.coords.end, @@ -4409,6 +4412,7 @@ delayed_reflow_of_normal_grid(struct terminal *term) term->interactive_resizing.old_screen_rows = 0; term->interactive_resizing.new_rows = 0; term->interactive_resizing.old_hide_cursor = false; + term->interactive_resizing.selection_coords = (struct range){{-1, -1}, {-1, -1}}; /* Invalidate render pointers */ render_wait_for_preapply_damage(term); @@ -4760,8 +4764,11 @@ render_resize(struct terminal *term, int width, int height, uint8_t opts) term->interactive_resizing.grid = xmalloc(sizeof(*term->interactive_resizing.grid)); *term->interactive_resizing.grid = term->normal; - if (term->grid == &term->normal) + if (term->grid == &term->normal) { term->interactive_resizing.selection_coords = term->selection.coords; + term->selection.coords.start.row -= term->grid->view; + term->selection.coords.end.row -= term->grid->view; + } } else { /* We'll replace the current temporary grid, with a new * one (again based on the original grid) */ @@ -4799,9 +4806,6 @@ render_resize(struct terminal *term, int width, int height, uint8_t opts) .kitty_kbd = orig->kitty_kbd, }; - term->selection.coords.start.row -= orig->view; - term->selection.coords.end.row -= orig->view; - for (size_t i = 0, j = orig->view; i < term->interactive_resizing.old_screen_rows; i++, j = (j + 1) & (orig->num_rows - 1)) |
