Open jmoore34 opened 3 years ago
Unfortunately this is due to a workaround when fzf is invoked from a PSReadline handler. I have to call PSReadline's InvokePrompt
to redraw the prompt as PSReadline won't automatically redraw the prompt after a child process modifies the text buffer. I'm not sure how to fix this one, unless this is fixed in PSReadline.
Should someone file this bug against PSReadline
then?
I worked around this locally by adding:
function script:InvokePrompt()
{
$previousOutputEncoding = [Console]::OutputEncoding
[Console]::OutputEncoding = [Text.Encoding]::UTF8
try {
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
} finally {
[Console]::OutputEncoding = $previousOutputEncoding
}
}
And calling that instead of calling [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
directly. Not sure if this is something you will actually want in a pull request..., I said the same about this in https://github.com/PowerShell/PSReadLine/issues/2866#issuecomment-960788773, but who knows if it will ever get any attention... 🤷♂️
P.S. Does adding script:
do anything? Isn't that already the default scope of functions defined at the script level?
I also set Set-PSReadLineOption -ExtraPromptLineCount 2
since it seems to redraw the prompt better that way. (Using starship prompt)
Thank for for the investigation! I added your workaround and tested it locally. it looks great!
I created a prerelease version with your change: https://www.powershellgallery.com/packages/PSFzf/2.3.1-alpha
When PSFzf is used with a powerline (e.g. oh-my-posh), the special characters are replaced with question marks after fzf runs.
Reproduction steps:
Tested on latest version (2.2.6)
Additional note: This issue does not occur when fzf is called manually from the command line