mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
search: matches_next: don’t wrap around grid->num_rows
When bumping the iter’s start.row, we’re working with view-local coordinates. That is, 0 >= row < term->rows. This means it is wrong to and with grid->num_rows - 1, because a), ‘row’ should **never** be that big. And b), if we do, we’ll just end up in an infinite loop, where the next call to matches_next() just starts over from the beginning again (and eventually hitting the exact same place that got us started).
This commit is contained in:
parent
f7c29ee394
commit
d068e821d6
1 changed files with 6 additions and 2 deletions
8
search.c
8
search.c
|
|
@ -580,10 +580,14 @@ search_matches_next(struct search_match_iterator *iter)
|
|||
|
||||
if (iter->start.col >= term->cols) {
|
||||
iter->start.col = 0;
|
||||
iter->start.row++;
|
||||
iter->start.row &= grid->num_rows - 1;
|
||||
iter->start.row++; /* Overflow is caught in next iteration */
|
||||
}
|
||||
|
||||
xassert(iter->start.row >= 0);
|
||||
xassert(iter->start.row <= term->rows);
|
||||
xassert(iter->start.col >= 0);
|
||||
xassert(iter->start.col < term->cols);
|
||||
|
||||
if (match.start.row == term->search.match.row &&
|
||||
match.start.col == term->search.match.col)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue