From 18c10ea706584e2432f120c4ea7c187f5c957c5f Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 22 May 2020 11:30:58 +0100 Subject: treeview: If cancelling empty search, drop focus Signed-off-by: Daniel Silverstone --- desktop/treeview.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'desktop') diff --git a/desktop/treeview.c b/desktop/treeview.c index 48a031612..1d632bb63 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -915,6 +915,12 @@ static void treeview__search_cancel(treeview *tree, bool drop_focus) return; } + if (textarea_get_text(tree->search.textarea, NULL, 0) == 1) { + // If there's no text in the search box, we drop focus on a + // cancel. Note '1' because it includes the trailing \0 + drop_focus = true; + } + if (drop_focus) { tree->search.active = false; textarea_set_caret(tree->search.textarea, -1); -- cgit v1.2.3