From 3bc404b5a353194252415d1a1594aef7c831f091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 14 Jul 2020 12:59:36 +0200 Subject: [PATCH] selection: foreach: don't call callback for trailing multi-character cells --- selection.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); + } } }