Closed jbirnick closed 1 year ago
I hadn't thought about this, but it does make sense that the original input order should be prioritized. This line is the reason that entries are default-sorted by their order. If I recall correctly (I did write this years ago) the fuzzy searcher will assign the same score to both "XYZW" and "XY" when searching for "XY", so this was added to prioritize exact matches.
I suppose the correct behavior would be:
If the search string is empty
Order is preserved (aka no calls to sort_by_key)
If the search string is non-empty
Sort first by fuzzy match score
Then sort by length, smallest first
Then sort by the order from the input
I believe the non-empty case is already addressed. To implement the empty case, we'd just need to place the sort_by_key calls in an if(searchterm.len()) (or similar).
@jbirnick I won't be near a development environment for few days. While I can't edit/test this, I can review a pull request if you can confirm that the suggested edit works. Otherwise I'll get to this when I can.
Thank you!
Unfortunately I can't work myself into your code so quickly, so I guess it has to wait until you want to work on it. :/ But it's actually not much of a problem for me, I just wanted to note it.
When using the fuzzy plugin, then when starting dmenu, without having typed anything yet, the entries are not sorted by their input order, but by their length. I guess that is because they are compared to the empty string as a search string.
It's probably not intended to have this behavior, as often the input order for e.g. menus or clipboard managers matters and shouldn't be disturbed just because fuzzy search is enabled.