Skip to content

cursor position reset in raw mode #4559

@DarioDarko

Description

@DarioDarko

Checklist

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

Output of fzf --version

0.66.0 (8cdfb23)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

ive been testing the new raw mode, really great addition to fzf 👍️

however i came across this issue: if you use raw mode with --bind result:best (re)loading fzfs input resets the cursor position to the very first entry

# cursor on 2nd entry
fzf --bind 'load:pos(2)'

# cursor on 1st entry
fzf --bind 'load:pos(2)' --raw --bind result:best

this also happens every time you use reload or reload-sync, the cursor jumps to pos(1). after trying some options i found this workaround:

# doesnt work for setting initial cursor position
# but prevents cursor position from resetting on reload
fzf --bind 'load:pos(2)' --raw --bind result:best \
--bind 'load:unbind(result)' --bind 'change:rebind(result)' --bind 'ctrl-r:reload(ls)'

this is probably related to another issue im having:

when changing the query (quickly) there seems to be some kind of visual flicker, the first entry is highlighted for a split second. this also is solved by the workaround of un- and rebinding result

string="one
two
three"

# flicker
printf "%s" "$string" \
| fzf --raw --bind result:best --color current-bg:white

# no flicker
printf "%s" "$string" \
| fzf --raw --bind result:best --color current-bg:white \
--bind 'load:unbind(result)' --bind 'change:rebind(result)' 

to reproduce use the # flicker code above, type 't' and then quickly type and remove 'h' (to make the selection switch between 'two' and 'three'). the highlight sometimes hits 'one' for a few miliseconds, which causes the flicker

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions