diff options
author | Dirk <d-egg> | 2021-03-24 14:53:00 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-24 14:53:58 +0300 |
commit | c0a4c8c3fa68a7343a8444aaf4948f309adec4d6 (patch) | |
tree | 57333f095978bcb2f96666c571a29ed3fc424eda /source/blender | |
parent | 26b45448abf05dc709678cb821201b0721a51d76 (diff) |
Fix T86891: only sort query results for shortest string if there is a query
Differential Revision: https://developer.blender.org/D10802
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/string_search.cc | 6 |
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. */ |