aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCismonX <admin@cismon.net>2026-07-10 15:16:43 +0000
committerDaniel Eklöf <daniel@ekloef.se>2026-07-21 08:56:02 +0000
commit11e3fa0d59da71267e5c7f5cb16c502d15901eb7 (patch)
tree65646271c3e255b1f2c6eea4720b795b16509036
parentcsi: 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
-rw-r--r--CHANGELOG.md3
-rw-r--r--selection.c40
2 files changed, 20 insertions, 23 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c611f5ee..d180857f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -117,6 +117,8 @@
* Crash in `--server` mode, when a tracked notification is closed
after the associated terminal instance has been closed
([#2397][2397]).
+* Incorrect word boundary detection when selection words with a
+ multi-column character in the last column ([#2411][2411]).
[2353]: https://codeberg.org/dnkl/foot/issues/2353
[2352]: https://codeberg.org/dnkl/foot/issues/2352
@@ -126,6 +128,7 @@
[2370]: https://codeberg.org/dnkl/foot/issues/2370
[2364]: https://codeberg.org/dnkl/foot/issues/2364
[2397]: https://codeberg.org/dnkl/foot/issues/2397
+[2411]: https://codeberg.org/dnkl/foot/issues/2411
### Security
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];