diff options
| author | CismonX <admin@cismon.net> | 2026-07-10 15:16:43 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2026-07-21 08:56:02 +0000 |
| commit | 11e3fa0d59da71267e5c7f5cb16c502d15901eb7 (patch) | |
| tree | 65646271c3e255b1f2c6eea4720b795b16509036 /selection.c | |
| parent | csi: log warning when capping color/title stack (diff) | |
selection: fix word boundary check
This patch fixes rightmost boundary check for a word wrapped to
another line, where a multi-column character appears as the last
character in the original line.
Closes #2411
Diffstat (limited to 'selection.c')
| -rw-r--r-- | selection.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/selection.c b/selection.c index dad81994..c58457d8 100644 --- a/selection.c +++ b/selection.c @@ -464,38 +464,32 @@ selection_find_word_boundary_right(const struct terminal *term, struct coord *po bool have_seen_word = initial_is_word; while (true) { - int next_col = pos->col + 1; + int next_col = pos->col; int next_row = pos->row; const struct row *row = term->grid->rows[next_row]; - /* Linewrap */ - if (next_col >= term->cols) { - if (row->linebreak) { - /* Hard linebreak, treat as space. I.e. break selection */ - break; - } - - next_col = 0; - next_row = (next_row + 1) & (grid->num_rows - 1); - - if (grid_row_abs_to_sb(grid, term->rows, next_row) == 0) { - /* Scrollback wrap-around */ - break; - } - - row = grid->rows[next_row]; - } - - c = row->cells[next_col].wc; - while (c >= CELL_SPACER) { + do { + /* Linewrap */ if (++next_col >= term->cols) { + if (row->linebreak) { + /* Hard linebreak, treat as space. I.e. break selection */ + return; + } + next_col = 0; - if (++next_row >= term->rows) + next_row = (next_row + 1) & (grid->num_rows - 1); + + if (grid_row_abs_to_sb(grid, term->rows, next_row) == 0) { + /* Scrollback wrap-around */ return; + } + + row = grid->rows[next_row]; } + c = row->cells[next_col].wc; - } + } while (c >= CELL_SPACER); if (c >= CELL_COMB_CHARS_LO && c <= CELL_COMB_CHARS_HI) c = composed_lookup(term->composed, c - CELL_COMB_CHARS_LO)->chars[0]; |
