diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-07-07 11:08:42 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-09-04 11:11:45 +0300 |
commit | 2a24b3aaf4c846a5d98f783fef69946584865df9 (patch) | |
tree | 34b33b8512d0bc821f5ada704c37a868046869f1 /source/blender/editors/interface/interface_template_search_operator.c | |
parent | 92b8d7019b4b484dc3120b26a27a59a3c7dc5489 (diff) |
Fix T78084: Search does not accept text fragments everywhere
This was reported for the "Add Node" search functionality, but is
relevant in other searches as well.
So e.g. when searching for "Separate XYZ", typing "sep", then " " (with
the intention to type "X" next) would clear the search field. Now use
the same method (matching against all search words) as in F3 searching
('menu_search_update_fn') in other searches as well [searching IDs,
property objects, finding nodes,...]
This should give a much nicer search experience in general.
Note: this does not touch other searches in the Dopesheet, Outliner,
Filebrowser or User Preferences that have other search implementations.
Maniphest Tasks: T78084
Differential Revision: https://developer.blender.org/D8232
Diffstat (limited to 'source/blender/editors/interface/interface_template_search_operator.c')
-rw-r--r-- | source/blender/editors/interface/interface_template_search_operator.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_template_search_operator.c b/source/blender/editors/interface/interface_template_search_operator.c index 76a6abe22cb..21529a97c01 100644 --- a/source/blender/editors/interface/interface_template_search_operator.c +++ b/source/blender/editors/interface/interface_template_search_operator.c @@ -65,30 +65,23 @@ static void operator_search_update_fn(const bContext *C, uiSearchItems *items) { GHashIterator iter; + + /* Prepare BLI_string_all_words_matched. */ const size_t str_len = strlen(str); - const int words_max = (str_len / 2) + 1; + const int words_max = BLI_string_max_possible_word_count(str_len); int(*words)[2] = BLI_array_alloca(words, words_max); - const int words_len = BLI_string_find_split_words(str, str_len, ' ', words, words_max); for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); const char *ot_ui_name = CTX_IFACE_(ot->translation_context, ot->name); - int index; if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) { continue; } - /* match name against all search words */ - for (index = 0; index < words_len; index++) { - if (!ui_str_has_word_prefix(ot_ui_name, str + words[index][0], words[index][1])) { - break; - } - } - - if (index == words_len) { + if (BLI_string_all_words_matched(ot_ui_name, str, words, words_len)) { if (WM_operator_poll((bContext *)C, ot)) { char name[256]; const int len = strlen(ot_ui_name); |