aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-01-03 15:01:05 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-04 18:48:43 +0000
commit56f6e450b0287545744c27e63972d72b4815e028 (patch)
treed4b52487685534dac95971db8ef82765def65001
parentselection: update: simplify: multi-column chars don’t span line-wraps (diff)
selection: update: get start-row pointer *after* modifying the start row index
-rw-r--r--selection.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/selection.c b/selection.c
index 81baf677..35212ab2 100644
--- a/selection.c
+++ b/selection.c
@@ -561,11 +561,6 @@ selection_update(struct terminal *term, int col, int row)
struct coord new_start = term->selection.start;
struct coord new_end = {col, term->grid->view + row};
- size_t start_row_idx = new_start.row & (term->grid->num_rows - 1);
- size_t end_row_idx = new_end.row & (term->grid->num_rows - 1);
- const struct row *row_start = term->grid->rows[start_row_idx];
- const struct row *row_end = term->grid->rows[end_row_idx];
-
/* Adjust start point if the selection has changed 'direction' */
if (!(new_end.row == new_start.row && new_end.col == new_start.col)) {
enum selection_direction new_direction = term->selection.direction;
@@ -698,6 +693,12 @@ selection_update(struct terminal *term, int col, int row)
break;
}
+ size_t start_row_idx = new_start.row & (term->grid->num_rows - 1);
+ size_t end_row_idx = new_end.row & (term->grid->num_rows - 1);
+
+ const struct row *row_start = term->grid->rows[start_row_idx];
+ const struct row *row_end = term->grid->rows[end_row_idx];
+
/* If an end point is in the middle of a multi-column character,
* expand the selection to cover the entire character */
if (new_start.row < new_end.row ||