Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface_utils.c')
-rw-r--r--source/blender/editors/interface/interface_utils.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index c413cac6023..690051ad735 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -30,6 +30,7 @@
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
+#include "BLI_alloca.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
@@ -53,18 +54,6 @@
#include "interface_intern.h"
-bool ui_str_has_word_prefix(const char *haystack, const char *needle, size_t needle_len)
-{
- const char *match = BLI_strncasestr(haystack, needle, needle_len);
- if (match) {
- if ((match == haystack) || (*(match - 1) == ' ') || ispunct(*(match - 1))) {
- return true;
- }
- return ui_str_has_word_prefix(match + 1, needle, needle_len);
- }
- return false;
-}
-
/*************************** RNA Utilities ******************************/
uiBut *uiDefAutoButR(uiBlock *block,
@@ -417,6 +406,12 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
char *name;
bool has_id_icon = false;
+ /* Prepare matching all words. */
+ 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);
+
/* build a temporary list of relevant items first */
RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop) {
@@ -462,7 +457,8 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
}
if (name) {
- if (skip_filter || BLI_strcasestr(name + name_prefix_offset, str)) {
+ if (skip_filter ||
+ BLI_string_all_words_matched(name + name_prefix_offset, str, words, words_len)) {
cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
cis->data = itemptr.data;
cis->name = BLI_strdup(name);