aboutsummaryrefslogtreecommitdiff
path: root/search.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-28 15:26:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-28 15:28:26 +0000
commitb8b43e2eabfd8647a9fc41d28cf7ea0003c03b2c (patch)
tree7aac4a3f0d011782958b6f4584fc93a9f062e48e /search.c
parentsearch: start search in current view, rather than from end-of-output (diff)
search: fix start/end row in selection
Diffstat (limited to 'search.c')
-rw-r--r--search.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/search.c b/search.c
index 903645e5..82902e6c 100644
--- a/search.c
+++ b/search.c
@@ -161,11 +161,25 @@ search_update(struct terminal *term)
if (start_row != term->search.match.row ||
start_col != term->search.match.col)
{
- selection_start(term, start_col, start_row - term->grid->view);
+ int selection_row = start_row - term->grid->view;
+ while (selection_row < 0)
+ selection_row += term->grid->num_rows;
+
+ assert(selection_row >= 0 &&
+ selection_row < term->grid->num_rows);
+ selection_start(term, start_col, selection_row);
}
/* Update selection endpoint */
- selection_update(term, end_col, end_row - term->grid->view);
+ {
+ int selection_row = end_row - term->grid->view;
+ while (selection_row < 0)
+ selection_row += term->grid->num_rows;
+
+ assert(selection_row >= 0 &&
+ selection_row < term->grid->num_rows);
+ selection_update(term, end_col, selection_row);
+ }
/* Update match state */
term->search.match.row = start_row;