diff options
| -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)) |
