diff options
Diffstat (limited to 'source/blender/editors/interface/interface_template_search_menu.c')
-rw-r--r-- | source/blender/editors/interface/interface_template_search_menu.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.c index 667dcfd935d..5bde51846a8 100644 --- a/source/blender/editors/interface/interface_template_search_menu.c +++ b/source/blender/editors/interface/interface_template_search_menu.c @@ -41,6 +41,7 @@ #include "BLI_math_matrix.h" #include "BLI_memarena.h" #include "BLI_string.h" +#include "BLI_string_search.h" #include "BLI_string_utils.h" #include "BLI_utildefines.h" @@ -993,19 +994,24 @@ static void menu_search_update_fn(const bContext *UNUSED(C), { struct MenuSearch_Data *data = arg; - /* Prepare BLI_string_all_words_matched. */ - const size_t str_len = strlen(str); - 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); + StringSearch *search = BLI_string_search_new(); - for (struct MenuSearch_Item *item = data->items.first; item; item = item->next) { - if (BLI_string_all_words_matched(item->drawwstr_full, str, words, words_len)) { - if (!UI_search_item_add(items, item->drawwstr_full, item, item->icon, item->state, 0)) { - break; - } + LISTBASE_FOREACH (struct MenuSearch_Item *, item, &data->items) { + BLI_string_search_add(search, item->drawwstr_full, item); + } + + struct MenuSearch_Item **filtered_items; + int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items); + + for (int i = 0; i < filtered_amount; i++) { + struct MenuSearch_Item *item = filtered_items[i]; + if (!UI_search_item_add(items, item->drawwstr_full, item, item->icon, item->state, 0)) { + break; } } + + MEM_freeN(filtered_items); + BLI_string_search_free(search); } /** \} */ |