summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTefatika <692720+Tefatika@users.noreply.github.com>2023-04-28 02:03:35 +0200
committerRĂ©mi Verschelde <rverschelde@gmail.com>2023-05-12 12:07:00 +0200
commite58001bd0d2eee1b174a0d8bd21ea18f97f25778 (patch)
treeb47dbce2018f7781592aa9f28f3b0af975fba7dd
parent9d257f10c0b6d180c88dc43aa76db2fe83e2ca29 (diff)
Command Palette search now also uses original English command names
Both localized and non localized names will be used while filtering The highest score between the two will be picked when determining the entries order (cherry picked from commit 09460cfaaf6524143b482c3082566f05ef227389)
-rw-r--r--editor/editor_command_palette.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp
index 1c598277dd..eb35eddeb1 100644
--- a/editor/editor_command_palette.cpp
+++ b/editor/editor_command_palette.cpp
@@ -75,9 +75,15 @@ void EditorCommandPalette::_update_command_search(const String &search_text) {
r.shortcut_text = E.value.shortcut;
r.last_used = E.value.last_used;
- if (search_text.is_subsequence_ofn(r.display_name)) {
+ bool is_subsequence_of_key_name = search_text.is_subsequence_ofn(r.key_name);
+ bool is_subsequence_of_display_name = search_text.is_subsequence_ofn(r.display_name);
+
+ if (is_subsequence_of_key_name || is_subsequence_of_display_name) {
if (!search_text.is_empty()) {
- r.score = _score_path(search_text, r.display_name.to_lower());
+ float key_name_score = is_subsequence_of_key_name ? _score_path(search_text, r.key_name.to_lower()) : .0f;
+ float display_name_score = is_subsequence_of_display_name ? _score_path(search_text, r.display_name.to_lower()) : .0f;
+
+ r.score = MAX(key_name_score, display_name_score);
}
entries.push_back(r);