kelleyma49 / PSFzf

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

After invoking Ctrl+T search stops and fzf hangs after typing the first character #87

Closed ntpeters closed 2 years ago

ntpeters commented 2 years ago

Repro Steps:

  1. Open a PowerShell Core instance in Windows Terminal
  2. Press Ctrl+T
  3. Type a search term

NOTE: Ctrl+R to search history works perfectly fine

Expected Behavior

Search is refined by the entered text, and am able to select a result with the arrow keys.

Actual Behavior

Search stops after the first character is entered, and fzf seems to freeze as it's no longer responsive to arrow keys or the escape key. It's possible to only backspace up to the first character entered, but it doesn't allow deleting that first character. Pressing enter selects the first entry, otherwise the only way to exit is Ctrl+C as it's not responsive to escape.

Screenshots

After entering a search term: image

After attempting to delete the entire search term: image

Versions

PowerShell Profile

Relevant lines in my profile:

Import-Module PSFzf
Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion }
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'

Environment

FZF_DEFAULT_COMMAND = 'fd --type file'

ntpeters commented 2 years ago

I think I found the issue. This line appears to be the problem: https://github.com/kelleyma49/PSFzf/blob/b97263a30addd9a2c84a8603382c92e4e6de0eeb/PSFzf.Base.ps1#L49

This should be invoking the command directly, rather than through cmd. If I make that change locally it seems to work fine. Looks like this should also be using the quoted directory path here too.

Beyond this fix, it'd be nice to have additional options (viaSet-PSFzfOption) to explicitly specify a format string for this command along with options to provide args for searching by directory only and colorization. It may not always be desirable to use $FZF_DEFAULT_COMMAND, so providing options to override that would be great.

kelleyma49 commented 2 years ago

The intended behavior is to pass the command to the native shell.

I believe the actual problem you are seeing is related to a regression I introduced into fzf itself a couple of months back. I have fixed the regression (https://github.com/junegunn/fzf/pull/2580), but fzf hasn't had an update in a couple of months. If you're setup to build go binaries, you can check out fzf's head to test the fix.

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.