mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -08:00
fix(pwsh): tweak the workaround for transient prompt
This commit is contained in:
parent
6723cba4b2
commit
0895aca72e
|
@ -125,12 +125,16 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
||||
}
|
||||
} finally {
|
||||
# If PSReadline is set to display suggestion list, this workaround is needed to clear the buffer below
|
||||
# before accepting the current commandline. The max amount of items in the list is 10, so 12 lines
|
||||
# are cleared (10 + 1 more for the prompt + 1 more for current commandline).
|
||||
if ((Get-PSReadLineOption).PredictionViewStyle -eq 'ListView') {
|
||||
# If PSReadline is set to display suggestion list, this workaround is needed to clear the buffer below
|
||||
# before accepting the current commandline. The max amount of items in the list is 10, so 12 lines
|
||||
# are cleared (10 + 1 more for the prompt + 1 more for current commandline).
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("`n" * [System.Math]::Min($Host.UI.RawUI.WindowSize.Height - $Host.UI.RawUI.CursorPosition.Y - 1, 12))
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::Undo()
|
||||
$terminalHeight = $Host.UI.RawUI.WindowSize.Height
|
||||
# only do this on an valid value
|
||||
if ([int]$terminalHeight -gt 0) {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("`n" * [System.Math]::Min($terminalHeight - $Host.UI.RawUI.CursorPosition.Y - 1, 12))
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::Undo()
|
||||
}
|
||||
}
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
||||
[Console]::OutputEncoding = $previousOutputEncoding
|
||||
|
|
Loading…
Reference in a new issue