diff options
author | Guilherme Felipe <guilhermefelipecgs@gmail.com> | 2019-09-08 12:24:33 -0300 |
---|---|---|
committer | Guilherme Felipe <guilhermefelipecgs@gmail.com> | 2019-09-08 13:08:34 -0300 |
commit | 481dbceed0d0610a6c689e3be448b7953994763e (patch) | |
tree | 5518713c6f66d8440710e9e30e67a6ddc188ce51 /editor | |
parent | e9f49a6d5ac88a6afca8a16f91a05f4fcdf5a589 (diff) |
Adds fuzzy search for help search dialog
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_help_search.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index af79c21f85..27e61362ed 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -338,10 +338,15 @@ 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(); - 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())) + 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)) match.methods.push_back(const_cast<DocData::MethodDoc *>(&class_doc.methods[i])); } if (search_flags & SEARCH_SIGNALS) @@ -431,9 +436,9 @@ 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_string.find(p_term) > -1; + return p_term.is_subsequence_of(p_string); else - return p_string.findn(p_term) > -1; + return p_term.is_subsequence_ofi(p_string); } void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_text) { |