From 9388237e2dcd5166db0b0384bf667c2bf3e8f7be Mon Sep 17 00:00:00 2001 From: follower Date: Wed, 1 Jul 2020 03:19:24 +1200 Subject: [PATCH] Revert "Adds fuzzy search for help search dialog" This reverts commit 481dbceed0d0610a6c689e3be448b7953994763e. Current fuzzy search implementation results in too many non-useful results. Could be re-added after result sort/filter/score functionality is added. See #30072 for example existing implementation. Fixes: #39128 Reverts: #32043 Fixed format style conflicts: editor/editor_help_search.cpp (cherry picked from commit 55d706c352fd3cbb25418201053bc0d688ee88d4) --- editor/editor_help_search.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 700d9b692bb..06ae7a19439 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -344,16 +344,12 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { if (search_flags & SEARCH_METHODS) for (int i = 0; i < class_doc.methods.size(); i++) { String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower(); - String aux_term = (search_flags & SEARCH_CASE_SENSITIVE) ? term : term.to_lower(); - - if (aux_term.begins_with(".")) - aux_term = aux_term.right(1); - - if (aux_term.ends_with("(")) - aux_term = aux_term.left(aux_term.length() - 1).strip_edges(); - - if (aux_term.is_subsequence_of(method_name)) + if (method_name.find(term) > -1 || + (term.begins_with(".") && method_name.begins_with(term.right(1))) || + (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) || + (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) { match.methods.push_back(const_cast(&class_doc.methods[i])); + } } if (search_flags & SEARCH_SIGNALS) for (int i = 0; i < class_doc.signals.size(); i++) @@ -440,11 +436,11 @@ bool EditorHelpSearch::Runner::_phase_select_match() { } bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const { - - if (search_flags & SEARCH_CASE_SENSITIVE) - return p_term.is_subsequence_of(p_string); - else - return p_term.is_subsequence_ofi(p_string); + if (search_flags & SEARCH_CASE_SENSITIVE) { + return p_string.find(p_term) > -1; + } else { + return p_string.findn(p_term) > -1; + } } void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_text) {