junegunn / fzf

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

fzf sixels image preview empty on Windows Terminal Preview + pwsh + chafa on Windows #3995

Open ykhan21 opened 2 months ago

ykhan21 commented 2 months ago

Checklist

Output of fzf --version

0.55.0 (fc69308)

OS

Shell

Problem / Steps to reproduce

Windows Terminal Preview now supports sixels. The stable release of Windows Terminal does not yet support it.

Problem:

In pwsh, on Windows Terminal Preview, when you run ls -name *.png | fzf --preview 'chafa -s 50x50 -f sixels {}', the preview window is empty.

Steps:

  1. Get Windows Terminal Preview here: (https://github.com/microsoft/terminal/releases/tag/v1.22.2362.0).
  2. Run scoop install fzf chafa.
  3. Run ls -name *.png | fzf --preview 'chafa -s 50x50 -f sixels {}' in directory that has png files.
lunrenyi commented 2 months ago

I also encountered a similar problem, and I was able to reproduce it on Windows Terminal + gitbash:

echo hello | fzf --preview='type ls'

企业微信截图_17213711123827 企业微信截图_17213711396279

ykhan21 commented 2 months ago

This is issue related to sixels image previews on Windows. Your issue seems to be related to text previews.

Also, I cannot reproduce your issue. See the image below. image This is on Git Bash + Windows Terminal.

What version is your git, fzf, and Windows Terminal? And what font do you use in Windows Terminal?

lunrenyi commented 2 months ago

This is issue related to sixels image previews on Windows. Your issue seems to be related to text previews.

Also, I cannot reproduce your issue. See the image below. image This is on Git Bash + Windows Terminal.

What version is your git, fzf, and Windows Terminal? And what font do you use in Windows Terminal?

ykhan21 commented 2 months ago

This is issue related to sixels image previews on Windows. Your issue seems to be related to text previews. Also, I cannot reproduce your issue. See the image below. image This is on Git Bash + Windows Terminal. What version is your git, fzf, and Windows Terminal? And what font do you use in Windows Terminal?

  • Window version: windows 11 家庭中文版 23H2 22631.4037
  • Git version: 2.42.0.windows.2
  • Windows Terminal version: 1.20.11781.0
  • fzf version: 0.55.0
  • Font: Cascadia Mono

I can't reproduce it with Cascadia Mono. The preview works for me.

junegunn commented 2 months ago

Does it work in non-fullscreen mode? e.g. --height=-1

ykhan21 commented 2 months ago

Yes, ls -name *.png | fzf --height=-1 --preview 'chafa -s 50x50 -f sixels {}' works.

ykhan21 commented 2 months ago

Also, if the image is too large and it is displayed, some residue is left from the large image when you go to a smaller image. Here, I have --height=40%.

  1. Large image: image
  2. Going to a smaller image: image
ykhan21 commented 2 months ago

Yes, ls -name *.png | fzf --height=-1 --preview 'chafa -s 50x50 -f sixels {}' works.

This works, but clicking to select something is broken.

stevenwalton commented 2 months ago

I just saw this issue and I have 2 relevant issues open in the chafa project. See Chafa-#217 and Chafa-#218. Also a issue in wezterm which I think is more related to #3646 and #3486 but I suspect there are underlying issues connecting all of these. There's additional complexity introduced when using ssh and tmux fwiw.

I believe there are overlapping issues with fzf and chafa. Why I came here in the first place was actually to ask about $FZF_PREVIEW_COLUMNS and $FZF_PREVIEW_LINES since these do not appear to be calculated in a way that is compatible with chafa's (though if you read the issue there's some confusion there too).

I'll keep working with the chafa team but it may be good to at least have these cross linked and note that this issue appears to be cross platform.

junegunn commented 1 month ago

It's a long story.

We currently have two different renderer implementations for Windows, one is based on tcell library which is used when opening fzf in full-screen mode. The other is "light renderer" which was added later to support --height option on Windows.

  1. https://github.com/junegunn/fzf/blob/master/src/tui/tcell.go
  2. https://github.com/junegunn/fzf/blob/master/src/tui/light_windows.go

"Light" renderer has image support (using simple/naive pass-through mechanism), but tcell renderer does not, so that's why image is only shown when --height is given.

I tried removing the tcell renderer and using the light renderer even in full-screen mode, but it turned out to have an issue with non-ASCII characters, so I had to revert the decision.

https://github.com/junegunn/fzf/commit/559fb7ee4552312f59a4bbe428199db9f5aa1247

We need to find a way to fix https://github.com/junegunn/fzf/issues/3799