treeview: If cancelling empty search, drop focus

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2020-05-22 11:30:58 +01:00
parent 1a836c9bc4
commit 18c10ea706
No known key found for this signature in database
GPG Key ID: C30DF439F2987D74

View File

@ -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);