From 56f6e450b0287545744c27e63972d72b4815e028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 3 Jan 2021 16:01:05 +0100 Subject: [PATCH] selection: update: get start-row pointer *after* modifying the start row index --- selection.c | 11 ++++++----- 1 file 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 ||