junegunn/fzf

When sending reload(...) + preview(...) during the same event, the preview is reset

noahmayr opened this issue · 1 comments

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.49.0 (brew)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Reproduction:

  1. Run the following example
SHELL=/bin/sh LIST="a\nb\nc" fzf --preview 'echo {}'  --bind 'start:reload(echo $LIST)' --bind 'ctrl-p:reload(echo $LIST)+preview(echo "Hello World")
  1. Press ctrl-p to switch to a temporary preview showing "Hello World"

Expected:
The list is reloaded and the preview shows "Hello World" and goes back to the configured preview when navigating through the list

Actual:
The list is reloaded, the preview quickly flashes "Hello World" before showing the preview configured by --preview

Both reload and preview actions run asynchronously, so there is no guarantee that they finish in the specified order.

To give a better example:

echo alice | fzf --preview 'echo Hello {}' --bind 'space:reload(sleep 1; echo bob)+preview(echo Hi {})'

I'm not sure what you're trying to achieve with the actions, but it looks like you need a different strategy.