-
Notifications
You must be signed in to change notification settings - Fork 811
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
boost for first letter matches #5365
Conversation
src/textual/fuzzy.py
Outdated
@@ -40,6 +40,10 @@ def __init__( | |||
".*?".join(f"({escape(character)})" for character in query), | |||
flags=0 if case_sensitive else IGNORECASE, | |||
) | |||
self._first_word_regex = compile( |
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.
Is a new Matcher
created on each key press in the command palette?
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.
Yeah
Actually, I've nerd sniped myself. We can do so much better with the matching, but regexes aren't going to be enough. |
Putting this on hold. I'm going to show great strength of character and not work on this, because there are higher priorities right now. |
@willmcgugan Do you want to merge this to get the improvement in or stick with what we have? |
Going to hold off merging this. It's not quite a 100% improvement. |
@darrenburns slept on it, and came up with this. You may want to check it against Posting. |
Cool - I'll try it against Posting soon. |
The current highlighting is the best score. The way it is highlighted includes the You can match spaces, but I agree not highlighting them would be better. |
Wait, I see what you mean. It could match I may be able to tweak the heuristic. ATM it gives a boost to single words. It could boost based on the least number of groups. |
@darrenburns tweaked the heuristic so it favors matches with fewer groups. |
My estimate for a reasonable maximum on the number of loops was too low. Seems to work well with your example now. "exp res" puts response at the top. |
Tweak to the command palette matcher to boost matches for the first word(s).
Consider the system commands. If I were to type "SS" I would get "Show Keys and Help Panel". Now I get "Save Screenshot" because I'm matching the first letters.
Knowing this makes it easier to get a precise match.