Implement streaming preview window#2215
Conversation
e4553d5 to
7a004d0
Compare
|
I see some issues on some of my custom scripts. Only the first line is shown even after the preview has fully loaded. When I start to scroll to the bottom, then I see the second line and the ones after that. I'm trying to create a simple example. |
|
Actually it can be reproduced simply with the following : FZF_DEFAULT_OPTS="" ./bin/fzf --preview 'echo "1"; sleep 1; echo 2' |
|
You can also reproduce the same issue (probably), with the following : Here, on my computer, only the first 3 numbers are shown (numbers 1 to 3). with : it writes number from 1 to 8. |
|
with everything works fine, so there is something special happening near 1 tenth of a second. |
|
Nice find, 63444b4 should fix that. |
|
I'm also seeing an issue where fzf not terminating the running command when the cursor is moved. Need further investigation. |
…ll offset
rg --line-number --no-heading --color=always ^ |
fzf --delimiter : --ansi --preview-window '+{2}-/2' \
--preview 'sleep 1; bat --style=numbers --color=always --pager=never --highlight-line={2} {1}'
|
There's one behavior I'm not sure is intended : When I run the following : It shows the 1/20 while loading, even though the preview does not have a scroll. After the sleep and the echo foo however, the 1/20 disappears. I suggest to put only the loading screen in this case, not the 1/20 part. Maybe to avoid some "jittering", it would make more sense to put the loading on the right of the pagination, or maybe one line below that. |
|
This is the intended behavior as of now. You can see there's a braille character indicating that the stream is open (i.e. # `⠋ 1/20` disappears when the stream is closed
fzf --preview ' yes | head -n 20; sleep 5; echo foo ; ' --preview-window 'up:nohidden'
# `1/1020` remains (spinner on the left gone)
fzf --preview ' yes | head -n 20; sleep 5; seq 1000; sleep 1' --preview-window 'up:nohidden'One idea is to only print |
Yes, exactly, that is what I thought would make more sense, but I also would understand that you'd prefer to keep current behavior. |
|
I have just tested again and it seems to work well for me. |
|
I'm going to merge this as it all seems to be working fine and test it over the next few days. Please let me know if you find any issues. |
|
Yes, sure I will ! |
Fix junegunn#2212 # Will start rendering after 200ms, update every 100ms fzf --preview 'for i in $(seq 100); do echo $i; sleep 0.01; done' # Should print "Loading .." message after 500ms fzf --preview 'sleep 1; for i in $(seq 100); do echo $i; sleep 0.01; done' # The first line should appear after 200ms fzf --preview 'date; sleep 2; date' # Should not render before enough lines for the scroll offset are ready rg --line-number --no-heading --color=always ^ | fzf --delimiter : --ansi --preview-window '+{2}-/2' \ --preview 'sleep 1; bat --style=numbers --color=always --pager=never --highlight-line={2} {1}'

Preliminary implementation of the streaming preview window. Please test and report any bugs. Fix #2212.
/ping @p-kolacz @edi9999