-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made the search results more specific. #33578
Conversation
Here's a tip: In the description, put "Fix(es)"/"Close(s)" followed by the issue number to trigger the automatic closure of the issue. This is better than putting it in the title. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works really well.
I'm not sure about the performance in really big projects (for
loop with findn
s looks expensive), but I tested with ~800 scenes and it's bearable in debug build, so I think it should be ok.
@KoBeWi @YeldhamDev Thanks for reviewing. I also had the same concern but other functions like find and find_last also have the same time complexity. So I thought about using this function only. |
@code-xD |
My concern is that you are iterating every character in paths and they sometimes could be lengthy. I wonder if it's possible to optimize it without making it less accurate. Although as I said, it's fast enough anyways. Most people probably won't even notice any slowdown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to still work as good after your recent changes, but is noticeably faster. Nice.
I'd cherrypick it for 3.2.
I found about |
Remember to squash your commits: https://docs.godotengine.org/en/3.1/community/contributing/pr_workflow.html#mastering-the-pr-workflow-the-rebase |
Also, that last commit seems to be for something completely different. |
@YeldhamDev @KoBeWi Added another commit related to issue #33425 which improves the code suggestions. If it's all fine maybe this PR can be merged. |
I would've been better if you created another PR for that commit. |
Sure will do. |
editor/quick_open.cpp
Outdated
if (search == path) { | ||
return 1.2f; | ||
} else if ((pos = path.rfindn(search)) != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use statements in if
conditions, please change it to:
} else {
int pos = path.rfindn(search);
if (pos != -1) {
return 1.1f + 0.09 / (path.length() - pos + 1);
}
}
I think a comment explaining the logic of the weighing would be useful too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akien-mga I have made the required changes. The logic of the code is when we enter a keyword for file searching we prioritise files over folder. The current system yields the whole directory of the file in which filename is actually in the last. So by getting the first occurrence of the keyword from last which is then mapped such that the score lies between 1.1f to 1.19f where the occurrence of substring on the right side of the string has lesser score than that on the left side because the folders exist on the left side while the files on the right.
Sir, I also had another problem which is I am not able to squash my commits. The last commit I made was few months back so it is difficult to track back to that commit and fixup it.
Rebased and amended the commit to improve code style and commit log. |
When finding a substring, the rating is biased towards substrings at the end of the path. Fixes godotengine#33504.
Thanks! |
Cherry-picked for 3.2.2. |
Fixes #33504. Added an algorithm which defines the score more accurately for the search results.
The algorithm gives more score to a search result if substring matches towards the end.