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

Unexpected reordering when using --scheme=history #3645

Closed
5 of 10 tasks
romkatv opened this issue Feb 21, 2024 · 5 comments
Closed
5 of 10 tasks

Unexpected reordering when using --scheme=history #3645

romkatv opened this issue Feb 21, 2024 · 5 comments
Assignees
Labels

Comments

@romkatv
Copy link
Contributor

romkatv commented Feb 21, 2024

  • 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

Run:

printf '%s\n' '/a/b' '/b' | fzf --scheme=history --query='/b'

Expected: no reordering of elements:

  /b
> /a/b
  2/2 ─────────────────
> /b

Actual: the elements are reordered:

  /a/b
> /b
  2/2 ─────────────────
> /b

Output of fzf --version: 0.46.1 (3c0a630).

Alternative reproduction steps:

  1. Run: HISTFILE= FZF_DEFAULT_OPTS= bash --norc
  2. Run: source shell/key-bindings.bash
  3. Run: /b
  4. Run: /a/b
  5. Press: Ctrl-R

Expected: history entries are ordered by their number: 1 2 3.

Actual: history entries are out of order: 1 3 2.

image

@junegunn junegunn self-assigned this Feb 22, 2024
@junegunn junegunn added the bug label Feb 22, 2024
@junegunn
Copy link
Owner

Thanks for the report. Should be fixed now.

fzf was giving a higher score on / of /b because it is on the boundary, but it was giving zero bonus point to the second / of /a/b, which caused fzf to prefer the first /, resulting in a lower score in total. But this was a bug. / should be given the bonus point for non-word characters.

@romkatv
Copy link
Contributor Author

romkatv commented Feb 22, 2024

Thanks for the quick fix!

Do I understand correctly that --scheme=history is sufficient to disable reordering in all circumstances? If not, what is the right combination of commandline options to disable reordering?

@junegunn
Copy link
Owner

No, if you do not want fzf to sort the list at all, you should use --no-sort option.

@junegunn
Copy link
Owner

When you use the CTRL-R binding, you can press CTRL-R again to toggle sorting.

If you want to see the commands in chronological order, press CTRL-R again which toggles sorting by relevance

@romkatv
Copy link
Contributor Author

romkatv commented Feb 22, 2024

Thank you for the helpful answers.

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

No branches or pull requests

2 participants