mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(pwsh): cache tooltip command to avoid duplicate CLI calls
resolves #3394
This commit is contained in:
parent
481878262b
commit
d124909912
|
@ -20,6 +20,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
||||||
$script:ShellName = "::SHELL::"
|
$script:ShellName = "::SHELL::"
|
||||||
$script:PSVersion = $PSVersionTable.PSVersion.ToString()
|
$script:PSVersion = $PSVersionTable.PSVersion.ToString()
|
||||||
$script:TransientPrompt = $false
|
$script:TransientPrompt = $false
|
||||||
|
$script:ToolTipCommand = ""
|
||||||
$env:POWERLINE_COMMAND = "oh-my-posh"
|
$env:POWERLINE_COMMAND = "oh-my-posh"
|
||||||
$env:POSH_PID = $PID
|
$env:POSH_PID = $PID
|
||||||
$env:CONDA_PROMPT_MODIFIER = $false
|
$env:CONDA_PROMPT_MODIFIER = $false
|
||||||
|
@ -122,6 +123,11 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
||||||
$cleanPSWD = Get-CleanPSWD
|
$cleanPSWD = Get-CleanPSWD
|
||||||
$command = $null
|
$command = $null
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$null)
|
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$null)
|
||||||
|
$command = $command.Trim().Split(" ", 2) | Select-Object -First 1
|
||||||
|
if ($command -eq $script:ToolTipCommand) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$script:ToolTipCommand = $command
|
||||||
$standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "tooltip", "--error=$script:ErrorCode", "--shell=$script:ShellName", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--command=$command", "--shell-version=$script:PSVersion"))
|
$standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "tooltip", "--error=$script:ErrorCode", "--shell=$script:ShellName", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--command=$command", "--shell-version=$script:PSVersion"))
|
||||||
Write-Host $standardOut -NoNewline
|
Write-Host $standardOut -NoNewline
|
||||||
$host.UI.RawUI.CursorPosition = $position
|
$host.UI.RawUI.CursorPosition = $position
|
||||||
|
|
Loading…
Reference in a new issue