Merge pull request #33578 from code-xD/master

Made the search results more specific.
This commit is contained in:
Rémi Verschelde 2020-04-29 13:57:25 +02:00 committed by GitHub
commit 4b4fc2ea55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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());
}