diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2026-09-02 12:22:01 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2026-09-10 06:37:01 +0000 |
| commit | e6b286403f08163e914eb8ff5af06999dec52214 (patch) | |
| tree | fd980a2503bdf1ab41ba9247191ff70a2ce8e3c8 /selection.c | |
| parent | grid: reflow: Preserve cells with background color (diff) | |
selection: don't include spacer pad cells when extending the selection to cover all of a multi-cell character
When the selection starts or ends in the middle of a multi-cell
character, we stretch the selection so that all of the cells belonging
to the character is selected.
When we do this, we do *not* want trailing pad cells to be included in
the selection.
Diffstat (limited to 'selection.c')
| -rw-r--r-- | selection.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/selection.c b/selection.c index 554d61b4..1a4e22ea 100644 --- a/selection.c +++ b/selection.c @@ -1255,8 +1255,17 @@ 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]; - /* If an end point is in the middle of a multi-column character, - * expand the selection to cover the entire character */ + /* + * If an end point is in the middle of a multi-column character, + * expand the selection to cover the entire character. + * + * Note that we check for CELL_SPACER+0 *inclusive* when backing + * off. We do *not* want the point to be inside the pad area. + * + * But, we check for CELL_SPACER+0 *exclusive* when moving forward + * _into_ the multi-cell character. Again, because we do *not* + * want the point to be inside the pad area. + */ if (new_start.row < new_end.row || (new_start.row == new_end.row && new_start.col <= new_end.col)) { @@ -1264,14 +1273,14 @@ selection_update(struct terminal *term, int col, int row) row_start->cells[new_start.col].wc >= CELL_SPACER) new_start.col--; while (new_end.col < term->cols - 1 && - row_end->cells[new_end.col + 1].wc >= CELL_SPACER) + row_end->cells[new_end.col + 1].wc > CELL_SPACER) new_end.col++; } else { while (new_end.col >= 1 && row_end->cells[new_end.col].wc >= CELL_SPACER) new_end.col--; while (new_start.col < term->cols - 1 && - row_start->cells[new_start.col + 1].wc >= CELL_SPACER) + row_start->cells[new_start.col + 1].wc > CELL_SPACER) new_start.col++; } |
