TreeSearch: Clear filter only when really necessary.

This commit is contained in:
Alexander Montag 2024-10-02 16:15:50 +00:00
parent 88a617aa42
commit f00d1bfb40
No known key found for this signature in database
GPG Key ID: 07FE50B35A2B7524
1 changed files with 2 additions and 4 deletions

View File

@ -66,9 +66,8 @@ void TreeSearch::_filter_tree() {
void TreeSearch::_filter_tree(TreeItem *p_item, bool p_parent_matching) { void TreeSearch::_filter_tree(TreeItem *p_item, bool p_parent_matching) {
bool visible = number_matches.has(p_item) | p_parent_matching; bool visible = number_matches.has(p_item) | p_parent_matching;
if (!visible) {
p_item->set_visible(visible); p_item->set_visible(visible);
}
bool is_matching = _vector_has_bsearch(matching_entries, p_item); bool is_matching = _vector_has_bsearch(matching_entries, p_item);
for (int i = 0; i < p_item->get_child_count(); i++) { for (int i = 0; i < p_item->get_child_count(); i++) {
_filter_tree(p_item->get_child(i), is_matching | p_parent_matching); _filter_tree(p_item->get_child(i), is_matching | p_parent_matching);
@ -475,7 +474,6 @@ void TreeSearch::update_search(Tree *p_tree) {
_update_matching_entries(search_mask); _update_matching_entries(search_mask);
_update_number_matches(); _update_number_matches();
_clear_filter();
_highlight_tree(); _highlight_tree();
if (search_mode == TreeSearchMode::FILTER) { if (search_mode == TreeSearchMode::FILTER) {
_filter_tree(); _filter_tree();