aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-01-03 14:37:51 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-04 18:48:43 +0000
commitfb9a95494dd0d6f55ec9ef08115b3b1ad1403305 (patch)
tree89a7b5878dd86322a4be996a503ee6a261a0268f /selection.c
parentselection: wrap pivot_{start,end}->row before accessing grid row array (diff)
selection: update: simplify: multi-column chars don’t span line-wraps
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/selection.c b/selection.c
index 78add510..81baf677 100644
--- a/selection.c
+++ b/selection.c
@@ -620,13 +620,11 @@ selection_update(struct terminal *term, int col, int row)
keep_going = wc == CELL_MULT_COL_SPACER;
- if (pivot_end->col == 0) {
- if (pivot_end->row > 0) {
- pivot_end->col = term->cols - 1;
- pivot_end->row--;
- }
- } else
- pivot_end->col--;
+ /* Multi-col chars shouldn’t span line-wraps */
+ assert(pivot_end->col > 0);
+ if (pivot_end->col == 0)
+ break;
+ pivot_end->col--;
}
} else {
bool keep_going = true;
@@ -637,13 +635,9 @@ selection_update(struct terminal *term, int col, int row)
keep_going = wc == CELL_MULT_COL_SPACER;
- if (pivot_start->col >= term->cols - 1) {
- if (pivot_start->row < term->rows - 1) {
- pivot_start->col = 0;
- pivot_start->row++;
- }
- } else
- pivot_start->col++;
+ if (pivot_start->col >= term->cols - 1)
+ break;
+ pivot_start->col++;
}
}