From 082e242ce5c954c59f52a6878a6d3794694a1182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 23 Apr 2022 12:28:12 +0200 Subject: [PATCH] search: matches_next: stop searching when start.row >= term->rows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As this means the last call to sarch_matches_next() found a match at the bottom of the view, and then set the iter’s *next* start position to a row outside the view. This is fine, but we need to handle it, by immediately stopping the iter. --- search.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/search.c b/search.c index 8f99fae7..337db697 100644 --- a/search.c +++ b/search.c @@ -539,7 +539,16 @@ search_matches_next(struct search_match_iterator *iter) /* First, return the primary match */ match = term->selection.coords; found = true; - } else { + } + + else if (iter->start.row >= term->rows) { + goto no_match; + } + + else { + xassert(iter->start.row >= 0); + xassert(iter->start.row < term->rows); + struct coord abs_start = iter->start; abs_start.row = grid_row_absolute_in_view(grid, abs_start.row);