Closed willmcgugan closed 1 day ago
This might be an issue with the matcher scoring?
from textual.fuzzy import Matcher
def test_match():
matcher = Matcher("hel")
help_match = matcher.match("Show keys and help panel")
quit_match = matcher.match("Quit the application")
assert help_match > quit_match
I don't fully understand the scoring, but I suspect the problem is the first character match:
Show keys and help panel
^ ^ ^
Quit the application
^^ ^
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
Sorry just to clarify for future reference, I'm a bit confused why this issue is closed? The command palette sorting described in the original issue is still the same on main?
If I type hel I get two results: Quit the application and show keys and help panel, in that order. I would expect the help panel to be on top as it is a better match according to the code in fuzzy.py.
I made it sort using the match score (I believe!), but never looked into any deficiencies in the scoring algorithm itself, as it seemed to give better results and I never checked the specific example in the original issue.
Shall we create a separate issue to cover improving the scoring and link to this?
The command palette doesn't sort the matches other than alphabetically.
There does seem to be code in there to rate matches, and the docs do say the score is used in sorting. But no sorting occurs.
You can see this with the current system commands. If I type hel I get two results:
Quit the application
andshow keys and help panel
, in that order. I would expect the help panel to be on top as it is a better match according to the code in fuzzy.py.