Skip to content
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

Tiebreak options do not suffice with nth #2537

Closed
5 of 10 tasks
xeruf opened this issue Jun 23, 2021 · 3 comments
Closed
5 of 10 tasks

Tiebreak options do not suffice with nth #2537

xeruf opened this issue Jun 23, 2021 · 3 comments
Assignees

Comments

@xeruf
Copy link
Contributor

xeruf commented Jun 23, 2021

  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Problem / Steps to reproduce

I have a nice fzf script to search through and install Arch Linux packages.
In it, I use --nth so I can see the repo but only search the actual package string.
However, I am unable to define any tiebreak algorithm that puts the best matches first.

Suppose the following scenario:

echo "aur\tdockerize\naur\tsystemd-docker\ncommunity\tdocker\t5.5" | fzf --nth 2

Searching for docker will yield one of the aur packages,
regardless of the tiebreak options.

In my day-to-day usage I encounter basically this,
except that there's lots more irrelevant results.

Workarounds

  • search for ^docker$
  • reorder the input so community packages appear first (pretty brittle)

Neither of these is reliable and convenient.
I think the solution would be a --tiebreak=matchlength option, which only takes the length of the match rather than the whole line into account.
And, again, sorting perfect matches first (#2285)

@0phoff
Copy link

0phoff commented Dec 6, 2021

I encountered exactly the same issue!

I assumed that --tiebreak=length would already take into account the substring we select with the --nth selector.
Wouldn't this be a possibility as well, to have the length tiebreak work on the --nth substring automatically, as I do not think there wouldn't really be a use-case where you want the total line length, instead of the matching line length.

@xeruf
Copy link
Contributor Author

xeruf commented Jan 23, 2022

Just encountered a similar issue again, as I use --tiebreak=index now to sort non-AUR packages always first.

But in this example, the perfect match "context" if very far behind, making me wonder why the algorithm resorted to a tiebreak here at all - you don't need a tiebreak to see that the first match is a lot worse, even with a very generic algorithm. Do we maybe have a regression here?
image

@xeruf xeruf mentioned this issue Jan 23, 2022
10 tasks
@junegunn junegunn self-assigned this Jul 28, 2022
@junegunn
Copy link
Owner

junegunn commented Aug 3, 2022

You might want to try the new --tiebreak=chunk in 0.32.0. It was designed to work well with or without --nth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants