From 275915228584e665f71266da30084c9ef5d67b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 27 Aug 2019 21:09:37 +0200 Subject: [PATCH] search: loop through the *entire* scrollback buffer --- search.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/search.c b/search.c index 992de851..a44ca7ec 100644 --- a/search.c +++ b/search.c @@ -66,11 +66,13 @@ search_update(struct terminal *term) LOG_DBG("search: update: starting at row=%d col=%d", start_row, start_col); +#define ROW_DEC(_r) ((_r) = ((_r) - 1 + term->grid->num_rows) % term->grid->num_rows) + /* Scan backward from current end-of-output */ - for (; start_row >= 0; start_row--) { + for (size_t r = 0; r < term->grid->num_rows; ROW_DEC(start_row), r++) { const struct row *row = term->grid->rows[start_row]; if (row == NULL) - break; + continue; for (; start_col >= 0; start_col--) { if (row->cells[start_col].wc != term->search.buf[0]) @@ -175,9 +177,12 @@ search_update(struct terminal *term) } /* No match */ + LOG_DBG("no match"); term->search.match = (struct coord){-1, -1}; term->search.match_len = 0; selection_cancel(term); + +#undef ROW_DEC } void