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 /render.c | |
| 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.
Diffstat (limited to 'render.c')
| -rw-r--r-- | render.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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)) |
