summaryrefslogtreecommitdiff
path: root/editor/quick_open.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/quick_open.cpp')
-rw-r--r--editor/quick_open.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index 4d9870235d..b872bc3dd4 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -113,12 +113,18 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) {
float EditorQuickOpen::_path_cmp(String search, String path) const {
+ // Exact match.
if (search == path) {
return 1.2f;
}
- if (path.findn(search) != -1) {
- return 1.1f;
+
+ // Substring match, with positive bias for matches close to the end of the path.
+ int pos = path.rfindn(search);
+ if (pos != -1) {
+ return 1.1f + 0.09 / (path.length() - pos + 1);
}
+
+ // Similarity.
return path.to_lower().similarity(search.to_lower());
}
@@ -265,8 +271,7 @@ void EditorQuickOpen::_notification(int p_what) {
connect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed));
search_box->set_clear_button_enabled(true);
- [[fallthrough]];
- }
+ } break;
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed));
} break;