junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
61.95k stars 2.34k forks source link

Command history sorting order #3831

Closed lxg208 closed 1 month ago

lxg208 commented 1 month ago

Checklist

Output of fzf --version

0.52.1 (6432f00)

OS

Shell

Problem / Steps to reproduce

I tried this both on WSL and standalone Ubuntu. When I type CTRL-R, then "cpD" I got following:

498 ycpD 497 ls -c|perl -pe '/\D/' 494 code pD

The command I want is ycpD, I remember I used to get it as the last one, but things changed a couple of weeks ago and I'm getting above sequence. I think it's not version related, I'm having the issue with 0.42.0 and 0.52.1

I think there are two issues here: 1. ycpD is used the last, it should appear at the bottom, 2. cpD are togather in ycpD, but has less priority then other two cases

And here is my FZF_CTRL_R_OPTS --bind 'ctrl-s:clear-selection,ctrl-d:execute-silent(grep -vxFf {+f2..} ~/.bash_history > ~/.edh90868068; cp ~/.edh90868068 ~/.bash_history)'

junegunn commented 1 month ago

We haven't changed the ranking algorithm for a while. What you're seeing is the way fzf scores the matches; matching characters at special positions (e.g. word boundary) are given higher bonus score. It was designed to work well in many cases, but it can't read your mind.