fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Actions first/last are inconsistent with up/down

Open maxaykin opened this issue 3 months ago • 4 comments

Checklist

  • [x] I have read through the manual page (man fzf)
  • [x] I have searched through the existing issues
  • [x] For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.65.2 (04a2dfac)

OS

  • [x] Linux
  • [ ] macOS
  • [ ] Windows
  • [ ] Etc.

Shell

  • [x] bash
  • [ ] zsh
  • [ ] fish

Problem / Steps to reproduce

Actions up/down move the cursor up/down independent of presence of --layout=reverse-list. Effect of actions first/last depends on whether the list is reversed. It would be more consistent to make them always act as top/bottom.

maxaykin avatar Oct 08 '25 08:10 maxaykin

If first/last are meant to move cursor to the best/worse match, there should be actions top/bottom probably.

maxaykin avatar Oct 08 '25 08:10 maxaykin

Ok, I suppose the following can be a workaround to move cursor to the top/bottom:

--bind 'alt-home:transform:[[ $FZF_DIRECTION == up ]] && echo last || echo first'
--bind 'alt-end:transform:[[ $FZF_DIRECTION == up ]] && echo first || echo last'

However, it is really not good to have such scripting and calls to the shell for very ordinary key actions

maxaykin avatar Oct 08 '25 12:10 maxaykin

If first/last are meant to move cursor to the best/worse match

Yes, they refer to the first and the last of the result list. When the list is sorted, the best match comes first. (Yeah, the new --raw mode kind of complicates the landscape. In that case, we should see first as the first item in the unsorted, original list.)

very ordinary key actions

I don't really use last since it points to the least relevant match, which I'm never interested in. But I can see what you're trying to do here. So you want bindings that brings cursor to the top and the bottom of the viewport for completeness' sake. I can understand that.

Unfortunately, top was the old name for first, and many users still rely on it in bindings like --bind change:top (https://github.com/search?q=%22bind+change%3Atop%22&type=code).

So if we were to introduce such actions, we need to choose different names. Something like ceil and floor could work, though they might be slightly confusing since they remind us of math functions.

junegunn avatar Oct 21 '25 11:10 junegunn

Maybe top-item/bottom-item or first-item/last-item?

maxaykin avatar Oct 21 '25 11:10 maxaykin