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/blenlib/intern/string_search.cc')
-rw-r--r--source/blender/blenlib/intern/string_search.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc
index 44baff1f5e3..25a13674932 100644
--- a/source/blender/blenlib/intern/string_search.cc
+++ b/source/blender/blenlib/intern/string_search.cc
@@ -432,9 +432,11 @@ int BLI_string_search_query(StringSearch *search, const char *query, void ***r_d
{
using namespace blender;
+ const StringRef query_str = query;
+
LinearAllocator<> allocator;
Vector<StringRef, 64> query_words;
- string_search::extract_normalized_words(query, allocator, query_words);
+ string_search::extract_normalized_words(query_str, allocator, query_words);
/* Compute score of every result. */
MultiValueMap<int, int> result_indices_by_score;
@@ -457,7 +459,7 @@ int BLI_string_search_query(StringSearch *search, const char *query, void ***r_d
Vector<int> sorted_result_indices;
for (const int score : found_scores) {
MutableSpan<int> indices = result_indices_by_score.lookup(score);
- if (score == found_scores[0]) {
+ if (score == found_scores[0] && !query_str.is_empty()) {
/* Sort items with best score by length. Shorter items are more likely the ones you are
* looking for. This also ensures that exact matches will be at the top, even if the query is
* a substring of another item. */