kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
787 stars 34 forks source link

Arrow keys are unusable when using Windows Terminal #84

Closed Namorzyny closed 2 years ago

Namorzyny commented 3 years ago

PSFzf Version: 2.2.6 PowerShell Version: 5.1.19041.906 Windows Version: 10.0.19043.985 Windows Terminal Version: 1.8.1521.0

Can't select items by arrow keys, just output ^[[A... and exit (like pressing Esc). In conhost.exe it works fine.

Screenshot 2021-06-08 193443

Namorzyny commented 3 years ago

This issue can't reproduce on my other computer with the same environment but without clink installed (https://chrisant996.github.io/clink/). It seems that clink injection causes this issue.

rashil2000 commented 3 years ago

@kelleyma49 would you mind reopening this issue?

Clink is really essential, I can't imagine uninstalling it.

Besides, all the keys work fine when history is searched through Ctrl+R, so why is Ctrl+T for file searching causing a problem?

rashil2000 commented 3 years ago

I have narrowed down the problem to this line: https://github.com/kelleyma49/PSFzf/blob/b97263a30addd9a2c84a8603382c92e4e6de0eeb/PSFzf.Base.ps1#L296

Specifying height in any way messes up the keys.

kelleyma49 commented 3 years ago

Are you starting PowerShell from clink? If I do that I can recreate your issue. My guess is that clink conflicting with Windows Terminal's VT sequence support (https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences).

rashil2000 commented 3 years ago

No, I'm starting it from the Windows Terminal profile.

FWIW, I can recreate this issue even on conhost (by running PowerShell Core directly from the start menu) - by defining an environment variable $Env:FZF_DEFAULT_OPTS="--height=40%".

kelleyma49 commented 3 years ago

I think I have a work around (see junegunn/fzf#2580). It's an issue with a change I made to fzf months ago. You'll have to wait for the code to get merged to fzf and for a new release to be created.

rashil2000 commented 3 years ago

Oh, okay, thanks for the quick fix!

I apologize if this sounds trivial, but I'm curious to know why this affects only Ctrl+T function and not Ctrl+R function?

kelleyma49 commented 2 years ago

fzf versions great than 0.27.3 should resolve this problem, so I'm closing this for now. Let me know if you see it again.