aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-01-03 15:06:04 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-04 18:48:44 +0000
commit4849e8f87459be043ddaad3a37e334df03e9209e (patch)
tree0f98a60ceeaa70f963e2b7eb6945d1e0143f1819
parentselection: update: get start-row pointer *after* modifying the start row index (diff)
selection: update: line-wraps are ok while moving pivot start/end point
This fixes an assertion triggered when selecting the upper left cell and dragging down. We would end up trying to decrement the pivot end point, hitting an assertion that only is valid while skipping spacers. Remove the assertion, and allow pivot points to be moved across line wraps, but take care not to move outside the visible screen area.
-rw-r--r--selection.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/selection.c b/selection.c
index 35212ab2..f9642719 100644
--- a/selection.c
+++ b/selection.c
@@ -615,11 +615,13 @@ selection_update(struct terminal *term, int col, int row)
keep_going = wc == CELL_MULT_COL_SPACER;
- /* Multi-col chars shouldn’t span line-wraps */
- assert(pivot_end->col > 0);
- if (pivot_end->col == 0)
- break;
- pivot_end->col--;
+ if (pivot_end->col == 0) {
+ if (pivot_end->row - term->grid->view <= 0)
+ break;
+ pivot_end->col = term->cols - 1;
+ pivot_end->row--;
+ } else
+ pivot_end->col--;
}
} else {
bool keep_going = true;
@@ -630,9 +632,13 @@ selection_update(struct terminal *term, int col, int row)
keep_going = wc == CELL_MULT_COL_SPACER;
- if (pivot_start->col >= term->cols - 1)
- break;
- pivot_start->col++;
+ if (pivot_start->col >= term->cols - 1) {
+ if (pivot_start->row - term->grid->view >= term->rows - 1)
+ break;
+ pivot_start->col = 0;
+ pivot_start->row++;
+ } else
+ pivot_start->col++;
}
}