Skip to content

Commit

Permalink
fix(pwsh): cache tooltip command to avoid duplicate CLI calls
Browse files Browse the repository at this point in the history
resolves #3394
  • Loading branch information
JanDeDobbeleer committed Jan 26, 2023
1 parent 4818782 commit d124909
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/shell/scripts/omp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
$script:ShellName = "::SHELL::"
$script:PSVersion = $PSVersionTable.PSVersion.ToString()
$script:TransientPrompt = $false
$script:ToolTipCommand = ""
$env:POWERLINE_COMMAND = "oh-my-posh"
$env:POSH_PID = $PID
$env:CONDA_PROMPT_MODIFIER = $false
Expand Down Expand Up @@ -122,6 +123,11 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
$cleanPSWD = Get-CleanPSWD
$command = $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"))
Write-Host $standardOut -NoNewline
$host.UI.RawUI.CursorPosition = $position
Expand Down

0 comments on commit d124909

Please sign in to comment.