-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Add fuzzy string matching to quick open search #98278
Conversation
@a-johnston How does this new algorithm work? There seems to be a lot more to it than the first two approaches. But it works pretty well. Opened a small PR to fix some C++ gotchas but whole thing looks good to me (though didn't look at any of the Dialog code). |
@samsface thanks for testing it out! The matching process is similar to the earlier ones, although there are definitely more helpers etc cluttering it up haha. It essentially is doing:
Scoring then prioritizes (in rough order of importance):
Results with equal scores are tie-broken first on length and then on their alphanumeric order, which is why
I hadn't even noticed that! Yeah I can add a way to the fuzzy search code to skip a given prefix, or we can change that part of the updated quick open popup to not include it to begin with. Also thanks for mentioning the PR; I didn't get an email or notification about it so I would've missed it otherwise. TIL! |
I just updated it to 1) add a slight tie-breaker penalty if it relies on case insensitive matching and 2) ignore |
I wonder if FuzzySearch can be used for autocompletion 🤔 We used to have something similar, but it was reverted. |
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.
Awesome stuff @a-johnston. The algorithm works super well.
There's one more optimization I'd like to apply (but in another PR) that in my testing cut most of the benchmarks by 50%. A cull during the search that discards results early if their score is considerably less than the current max. I noticed we spend a ton of time adding then removing results that had like, a score of 3 while the max sore is 100.
Ah yeah I was thinking about something similar but instead considering the future potential score a la an advent of code problem from last(?) year. If you have the branch ready, feel free to pr against https://github.com/a-johnston/godot/tree/fuzzy-search-rebase |
It's already fast enough (imo) so wouldn't want to delay the PR. Let me know if you need help with any coding work to get the PR merged. |
Haha well you piqued my curiosity so I wanted to try it before nuking the benchmark. I settled on a pretty tame early cull criteria of being 1) negative (so, bad and missing query characters) and 2) at least 50 away from the current max score because I noticed that although the top results were of course preserved, the combination of match length being squared and a 100 bonus being given to exact token matches resulted in a query of ie Although the changes are pretty small I won't include them here but yeah for a future pr that addresses this
|
cfc40ad
to
826baca
Compare
826baca
to
9a2081d
Compare
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.
Label
changes look good, string matching seems to work as expected.
77f72ad
to
0532c88
Compare
0532c88
to
408b66f
Compare
Should I rebase these changes down to fewer total commits or is it fine as is? |
Yes please squash your commits into one, with a clear commit message with the same title as the PR |
Co-authored-by: sam <samsface@gmail.com>
408b66f
to
3ac043c
Compare
Not planning on making any more changes unless things are requested here but just to add visibility
|
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.
Code looks good to me from a cursory review.
I trust that stakeholders have tested the algorithm well, I know there are Opinions™ regarding how fuzzy search should work, and every single change we've done so far brought its wave of discontents. Let's hope this time's the One Algorithm that Satisfies Them All.
Thanks! Congratulations on your first contribution! 🎉 |
Thank you!
Hopefully having added some relevant editor options helps with that :P |
This is a continuation of #82200 to implement godotengine/godot-proposals#7771. Rebasing the first PR against #56772 was pretty awkward so I ended up flattening the earlier changes with @samsface as a co-author. A bit more info and pre-flattened commits are available in this pr against sam's fork samsface#1.
Functionally this adds optional fuzzy searching and search highlighting in the results:
The highlighting on the grid items feels a bit hacky due to the centered text; I'd appreciate any tips to do it more cleanly. This is also my first time working on a nontrivial c++ codebase so I'd appreciate any general tips to be more idiomatic or if I'm using anything incorrectly. Also a few semi-related changes: