aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-14 10:59:36 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-14 10:59:36 +0000
commit3bc404b5a353194252415d1a1594aef7c831f091 (patch)
tree09bb96803b5931c11e84c346a1987636e62cde01
parentchangelog: 'not' -> 'now' (diff)
selection: foreach: don't call callback for trailing multi-character cells
-rw-r--r--selection.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/selection.c b/selection.c
index 62f131b1..3abe934c 100644
--- a/selection.c
+++ b/selection.c
@@ -135,6 +135,8 @@ foreach_selected_normal(
c++)
{
cb(term, row, &row->cells[c], c, data);
+ c += max(1, wcwidth(row->cells[c].wc)) - 1;
+ assert(c < term->cols);
}
start_col = 0;
@@ -165,8 +167,11 @@ foreach_selected_block(
struct row *row = term->grid->rows[real_r];
assert(row != NULL);
- for (int c = top_left.col; c <= bottom_right.col; c++)
+ for (int c = top_left.col; c <= bottom_right.col; c++) {
cb(term, row, &row->cells[c], c, data);
+ c += max(1, wcwidth(row->cells[c].wc)) - 1;
+ assert(c < term->cols);
+ }
}
}