kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
750 stars 35 forks source link

[bug] Invoke-PsFzfRipgrep custom $env:FZF_DEFAULT_COMMAND propagates to editor #267

Closed DanSM-5 closed 2 months ago

DanSM-5 commented 2 months ago

Description

Some of my custom keybindings that use fzf in (n)vim were not working properly under some circumstances. I tracked the issue down to the function Invoke-PsFzfRipgrep. It looks like the change to $env:FZF_DEFAULT_COMMAND with for the search string propagates to the call to Invoke-Expression -Command $cmd.

My keybinding was relaying on the $FZF_DEFAULT_COMMAND variable and it was breaking because of the above change.

Proposed solution

Calling $script:OverrideFzfDefaultCommand.Restore() right after the fzf command should prevent this issue and it should be fine to restore the command as the search has already been done.

Current workaround

Explicitly set $FZF_DEFAULT_COMMAND in my vimrc/init.vim to prevent the issue.