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:
-rw-r--r--source/blender/blenlib/intern/string_search.cc11
-rw-r--r--source/blender/blenlib/tests/BLI_string_search_test.cc10
-rw-r--r--source/blender/editors/include/UI_interface.h5
3 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc
index a466c124073..08ba473f96b 100644
--- a/source/blender/blenlib/intern/string_search.cc
+++ b/source/blender/blenlib/intern/string_search.cc
@@ -24,6 +24,10 @@
#include "BLI_string_utf8.h"
#include "BLI_timeit.hh"
+/* Right arrow, keep in sync with #UI_MENU_ARROW_SEP in `UI_interface.h`. */
+#define UI_MENU_ARROW_SEP "\xe2\x96\xb6"
+#define UI_MENU_ARROW_SEP_UNICODE 0x25b6
+
namespace blender::string_search {
static int64_t count_utf8_code_points(StringRef str)
@@ -350,8 +354,11 @@ void extract_normalized_words(StringRef str,
LinearAllocator<> &allocator,
Vector<StringRef, 64> &r_words)
{
- const uint32_t unicode_space = BLI_str_utf8_as_unicode(" ");
- const uint32_t unicode_right_triangle = BLI_str_utf8_as_unicode("▶");
+ const uint32_t unicode_space = (uint32_t)' ';
+ const uint32_t unicode_right_triangle = UI_MENU_ARROW_SEP_UNICODE;
+
+ BLI_assert(unicode_space == BLI_str_utf8_as_unicode(" "));
+ BLI_assert(unicode_right_triangle == BLI_str_utf8_as_unicode(UI_MENU_ARROW_SEP));
auto is_separator = [&](uint32_t unicode) {
return ELEM(unicode, unicode_space, unicode_right_triangle);
diff --git a/source/blender/blenlib/tests/BLI_string_search_test.cc b/source/blender/blenlib/tests/BLI_string_search_test.cc
index 0d1fd2cab96..aa1c0b41c44 100644
--- a/source/blender/blenlib/tests/BLI_string_search_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_search_test.cc
@@ -8,6 +8,9 @@
namespace blender::string_search::tests {
+/* Right arrow, keep in sync with #UI_MENU_ARROW_SEP in `UI_interface.h`. */
+#define UI_MENU_ARROW_SEP "\xe2\x96\xb6"
+
TEST(string_search, damerau_levenshtein_distance)
{
EXPECT_EQ(damerau_levenshtein_distance("test", "test"), 0);
@@ -30,14 +33,17 @@ TEST(string_search, get_fuzzy_match_errors)
EXPECT_EQ(get_fuzzy_match_errors("", "abc"), 0);
EXPECT_EQ(get_fuzzy_match_errors("hello", "hallo"), 1);
EXPECT_EQ(get_fuzzy_match_errors("hap", "hello"), -1);
- EXPECT_EQ(get_fuzzy_match_errors("armature", "▶restore"), -1);
+ EXPECT_EQ(get_fuzzy_match_errors("armature", UI_MENU_ARROW_SEP "restore"), -1);
}
TEST(string_search, extract_normalized_words)
{
LinearAllocator<> allocator;
Vector<StringRef, 64> words;
- extract_normalized_words("hello world▶test another test▶ 3", allocator, words);
+ extract_normalized_words("hello world" UI_MENU_ARROW_SEP "test another test" UI_MENU_ARROW_SEP
+ " 3",
+ allocator,
+ words);
EXPECT_EQ(words.size(), 6);
EXPECT_EQ(words[0], "hello");
EXPECT_EQ(words[1], "world");
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 0d6236a7728..67d034f4ab6 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -96,8 +96,9 @@ typedef struct uiTreeViewItemHandle uiTreeViewItemHandle;
#define UI_SEP_CHAR '|'
#define UI_SEP_CHAR_S "|"
-/* Separator for text in search menus. */
-#define UI_MENU_ARROW_SEP "▶"
+/* Separator for text in search menus (right pointing arrow).
+ * keep in sync with `string_search.cc`. */
+#define UI_MENU_ARROW_SEP "\xe2\x96\xb6"
/* names */
#define UI_MAX_DRAW_STR 400