From 92c61ec9b1cef3bf6d1da01db3310daff6bba522 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 2 Sep 2026 14:23:56 +0200 Subject: selection: don't allow the start/end-points to be inside spacer pad cells Having the start/end-points in the pad area made the spacer cells tracking points when reflowing the grid. This caused the spacer cells to be kept, instead of removed. --- selection.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'selection.c') diff --git a/selection.c b/selection.c index 1a4e22ea..1c432e75 100644 --- a/selection.c +++ b/selection.c @@ -1255,6 +1255,19 @@ selection_update(struct terminal *term, int col, int row) const struct row *row_start = term->grid->rows[start_row_idx]; const struct row *row_end = term->grid->rows[end_row_idx]; + /* + * Don't allow leading/trailing pad cells in the selection. Pull + * the start/endpoint that is inside the pad region into the + * multi-cell character, and then let the next step below move it + * to the beginning of the multi-cell character. + */ + while (unlikely(row_start->cells[new_start.col].wc == CELL_SPACER)) { + new_start.col--; + } + while (unlikely(row_end->cells[new_end.col].wc == CELL_SPACER)) { + new_end.col--; + } + /* * If an end point is in the middle of a multi-column character, * expand the selection to cover the entire character. -- cgit v1.3