diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-04-29 13:57:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 13:57:25 +0200 |
commit | 4b4fc2ea55ac43e799d08bbbdeeda830601b7fc8 (patch) | |
tree | abdf5470b7ede504c90d680f9afb9dd2f05fe812 | |
parent | b3da42942301e621b0fe64474dbbe0b39cef336b (diff) | |
parent | 8c66d800993e6c5884123fbb8ca868727830f717 (diff) |
Merge pull request #33578 from code-xD/master
Made the search results more specific.
-rw-r--r-- | editor/quick_open.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 1b4439f0a8..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()); } |