Skip to content

Commit

Permalink
Improve readability of TreeSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
monxa committed Sep 29, 2024
1 parent c909582 commit cb163eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions editor/tree_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ void TreeSearch::_update_number_matches() {
for (int i = 0; i < matching_entries.size(); i++) {
TreeItem *item = matching_entries[i];
while (item) {
int old_num_value = number_matches.has(item) ? number_matches.get(item) : 0;
number_matches[item] = old_num_value + 1;
int previous_match_cnt = number_matches.has(item) ? number_matches.get(item) : 0;
number_matches[item] = previous_match_cnt + 1;
item = item->get_parent();
}
}
Expand Down Expand Up @@ -253,8 +253,10 @@ TreeSearch::StringSearchIndices TreeSearch::_substring_bounds(const String &p_se
// Determine if the search should be case-insensitive.
bool is_case_insensitive = (p_search_mask == p_search_mask.to_lower());
String searchable_processed = is_case_insensitive ? p_searchable.to_lower() : p_searchable;

PackedStringArray words = p_search_mask.split(" ");
int word_position = 0;

for (const String &word : words) {
if (word.is_empty()) {
continue; // Skip empty words.
Expand Down
2 changes: 1 addition & 1 deletion editor/tree_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TreeSearch : public RefCounted {
void update_search(Tree *p_tree);
void notify_item_edited(TreeItem *p_item);

TreeSearch() { ERR_FAIL_MSG("TreeSearch needs a TreeSearchPanel to work properly"); }
TreeSearch() { ERR_FAIL_MSG("TreeSearch needs a TreeSearchPanel to work properly."); }
TreeSearch(TreeSearchPanel *p_search_panel);
};

Expand Down

0 comments on commit cb163eb

Please sign in to comment.