-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Sort perfect match first #2285
Comments
Mine gives |
Sorry, you are right:
even though I can now understand why the algorithm selects it, it is not intuitive. The tiebreak end is there mainly for filenames, but it shouldn't prefer a longer entry because of that. Unfortunately there is no option to weigh two tiebreakers (end and length), they can only be ordered. |
|
My point here is that I use fzf for paths in the overwhelming majority, and in that case it makes sense to use That tip does indeed sound nice, though when searching through rc files is not particularly useful, as they rarely have an extension by convention. The question remains whether the |
We did that, and it didn't turn out great. Sadly, there is no one-size-fits-all option. It's better to understand how the default ranking algorithm works and tweak the query string to assist this dumb filter to do a better job. fzf implements all major Readline key bindings so it's easy to move the cursor around and tweak the search terms once you get used to it.
|
Just realized that even in this case entering "dragon" will select "fire-dragon", so I can't enter anything more to get a better search result. The behavior is the same with a space:
But removing the delimiter sorts "dragon" first as soon as I enter a single 'd':
So I'm assuming you are splitting on non-word characters and the matching against the terms.
|
What do you mean? Did you revert it? |
Thanks for the input, but I'm not interested in fine-tuning the scoring algorithm because like I said above, fzf is a text filter and the criteria may not make sense with different types of input.
Yes, please read the commit message. |
I thought these changes would be pretty general. If you don't want to do more tweaking, I would suggest to at least pick the issue title back up and always prefer a perfect match. The percentage-match could also be an additional tiebreaker.
oh woops, I read it the other way around, sorry ^^ |
I am still interested in looking into improving this - look at this: |
Because, unfortunately, the current scoring algorithm doesn't have a mechanism to prefer the latter. The scores calculated by the algorithm are just the same for the two cases. Not saying there isn't room for improvement. We could try fine-tuning the algorithm. |
How about taking inspiration from https://github.com/jhawthorn/fzy/blob/master/ALGORITHM.md#fzys-scoring ? |
So your real problem here is that the default It looks like the algorithm of fzy isn't very different from that of fzf. The document you linked above is severely outdated and it describes the algorithm of fzf 0.14.0 and below. fzy doesn't have |
Favors the line with shorter matched chunk. A chunk is a set of consecutive non-whitespace characters. Unlike the default `length`, this new scheme works well with tabular input. # length prefers item #1, because the whole line is shorter, # chunk prefers item #2, because the matched chunk ("foo") is shorter fzf --height=6 --header-lines=2 --tiebreak=chunk --reverse --query=fo << "EOF" N | Field1 | Field2 | Field3 - | ------ | ------ | ------ 1 | hello | foobar | baz 2 | world | foo | bazbaz EOF If the input does not contain any spaces, `chunk` is equivalent to `length`. But we're not going to set it as the default because it is computationally more expensive. Close #2285 Close #2537 - Not the exact solution to --tiebreak=length not taking --nth into account, but this should work. And the added benefit is that it works well even when --nth is not provided. - Adding a bonus point to the last character of a word didn't turn out great. The order of the result suddenly changes when you type in the last character in the word producing a jarring effect.
man fzf
)Info
Problem / Steps to reproduce
I would expect number 2 to come out first here. My hunch is that space and minus are treated equally - whereas I think a space (or tab for that matter) is a much stronger word delimiter than a minus.
I encountered this during package search, where there is some extra info before and after the package name delimited with tabs, and thus a perfect match doesn't seem so perfect to fzf.
The text was updated successfully, but these errors were encountered: