Skip to content

Commit

Permalink
Workaround for missing PSReadLine prompt (#38)
Browse files Browse the repository at this point in the history
- Tells PSReadLine to redraw prompt after Invoke-Fzf is executed
- resolves #37
  • Loading branch information
kelleyma49 authored Mar 8, 2020
1 parent 0879d47 commit 465d3d9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion PSFzf.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ function Invoke-FzfPsReadlineHandlerProvider {
# catch custom exception
}

#HACK: workaround for fact that PSReadLine seems to clear screen
# after keyboard shortcut action is executed:
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()

if ($null -ne $result) {
# quote strings if we need to:
if ($result -is [system.array]) {
Expand Down Expand Up @@ -443,6 +447,11 @@ function Invoke-FzfPsReadlineHandlerHistory {
# ensure that stream is closed:
$reader.Dispose()
}

#HACK: workaround for fact that PSReadLine seems to clear screen
# after keyboard shortcut action is executed:
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()

if (-not [string]::IsNullOrEmpty($result)) {
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($result)
}
Expand Down Expand Up @@ -479,6 +488,10 @@ function Invoke-FzfPsReadlineHandlerHistoryArgs {
$reader.Dispose()
}

#HACK: workaround for fact that PSReadLine seems to clear screen
# after keyboard shortcut action is executed:
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()

if (-not [string]::IsNullOrEmpty($result)) {
# add quotes:
if ($result.Contains(" ") -or $result.Contains("`t")) {
Expand All @@ -505,7 +518,11 @@ function Invoke-FzfPsReadlineHandlerSetLocation {
if (-not [string]::IsNullOrEmpty($result)) {
Set-Location $result
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
} else {
#HACK: workaround for fact that PSReadLine seems to clear screen
# after keyboard shortcut action is executed:
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
}
}

function SetPsReadlineShortcut($Chord,[switch]$Override,$BriefDesc,$Desc,[scriptblock]$scriptBlock)
Expand Down

0 comments on commit 465d3d9

Please sign in to comment.