diff --git a/editor/tree_search.cpp b/editor/tree_search.cpp index 03a11cb..0b3a8f5 100644 --- a/editor/tree_search.cpp +++ b/editor/tree_search.cpp @@ -68,10 +68,16 @@ void TreeSearch::_filter_tree(const String &p_search_mask) { } TreeItem *first_counting_ancestor = cur_item; + bool parents_visible = true; while (first_counting_ancestor && !number_matches.has(first_counting_ancestor)) { + // Performance: we only need to check the first visible ancestor. This is already optimal because of the ordering in ordered_tree_items. + if (!first_counting_ancestor->is_visible()){ + parents_visible = false; + break; + } first_counting_ancestor = first_counting_ancestor->get_parent(); } - if (!first_counting_ancestor || !_vector_has_bsearch(matching_entries, first_counting_ancestor)) { + if (!parents_visible || !first_counting_ancestor || !_vector_has_bsearch(matching_entries, first_counting_ancestor)) { cur_item->set_visible(false); } }