summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-08-05 13:50:42 +0200
committerGitHub <noreply@github.com>2021-08-05 13:50:42 +0200
commit9e5ebce1d9f58456f690e7e6ac7b78ed593f203b (patch)
treefc497361095ab48cbe7fdada4e223059294eee7d /editor
parent66d968e4b62fe8e58091dc27ab35b2d7557d2e2a (diff)
parent580cb629865e5d215b1946e9625758cff6606582 (diff)
Merge pull request #50707 from SirQuartz/patch-26
Diffstat (limited to 'editor')
-rw-r--r--editor/quick_open.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index bda7540a23..ed94f859e2 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -118,6 +118,11 @@ void EditorQuickOpen::_update_search() {
float EditorQuickOpen::_score_path(const String &p_search, const String &p_path) {
float score = 0.9f + .1f * (p_search.length() / (float)p_path.length());
+ // Exact match.
+ if (p_search == p_path) {
+ return 1.2f;
+ }
+
// Positive bias for matches close to the beginning of the file name.
String file = p_path.get_file();
int pos = file.findn(p_search);
@@ -128,11 +133,11 @@ float EditorQuickOpen::_score_path(const String &p_search, const String &p_path)
// Positive bias for matches close to the end of the path.
pos = p_path.rfindn(p_search);
if (pos != -1) {
- return score * (0.8f - 0.1f * (float(p_path.length() - pos) / p_path.length()));
+ return 1.1f + 0.09 / (p_path.length() - pos + 1);
}
- // Remaining results belong to the same class of results.
- return score * 0.69f;
+ // Similarity
+ return p_path.to_lower().similarity(p_search.to_lower());
}
void EditorQuickOpen::_confirmed() {