From 251545203baa65364e491ddbe71ab3f8080bfe25 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jul 2021 17:53:29 +0200 Subject: search: reset match state when selection is cancelled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While we’re in scrollback search mode, the selection may be cancelled (for example, if the application is scrolling out the selected text). Trying to e.g. extend the search selection after this has happened triggered a crash. This fixes it by simply resetting the search match state when the selection is cancelled. Closes #644 --- search.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'search.c') diff --git a/search.c b/search.c index 8f28a656..2db66cc9 100644 --- a/search.c +++ b/search.c @@ -155,6 +155,13 @@ search_cancel(struct terminal *term) selection_cancel(term); } +void +search_selection_cancelled(struct terminal *term) +{ + term->search.match = (struct coord){-1, -1}; + term->search.match_len = 0; +} + static void search_update_selection(struct terminal *term, int start_row, int start_col, -- cgit v1.3 From 7092a72ce4554ac8b5261eeb7a26182cda8f927e Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jul 2021 17:57:25 +0200 Subject: search: redraw search box after selection has been cancelled --- search.c | 1 + 1 file changed, 1 insertion(+) (limited to 'search.c') diff --git a/search.c b/search.c index 2db66cc9..817f18b5 100644 --- a/search.c +++ b/search.c @@ -160,6 +160,7 @@ search_selection_cancelled(struct terminal *term) { term->search.match = (struct coord){-1, -1}; term->search.match_len = 0; + render_refresh_search(term); } static void -- cgit v1.3