fix(pwsh): get stack count correctly

This commit is contained in:
Jan De Dobbeleer 2022-05-22 11:33:26 +02:00 committed by Jan De Dobbeleer
parent a51716d5ac
commit eb11aa9081

View file

@ -2,6 +2,11 @@
if ($null -ne (Get-Module -Name "oh-my-posh-core")) { if ($null -ne (Get-Module -Name "oh-my-posh-core")) {
Remove-Module -Name "oh-my-posh-core" -Force Remove-Module -Name "oh-my-posh-core" -Force
} }
function Get-PoshStackCount {
return (Get-Location -Stack).Count
}
New-Module -Name "oh-my-posh-core" -ScriptBlock { New-Module -Name "oh-my-posh-core" -ScriptBlock {
$script:ErrorCode = 0 $script:ErrorCode = 0
$script:OMPExecutable = '::OMP::' $script:OMPExecutable = '::OMP::'
@ -272,13 +277,7 @@ Example:
} }
} }
$stackCount = (Get-Location -Stack).Count $stackCount = Get-PoshStackCount
try {
if (Test-Path Variable:/global:OMP_GLOBAL_SESSIONSTATE) {
$stackCount = $global:OMP_GLOBAL_SESSIONSTATE.Path.LocationStack('').Count
}
} catch {}
Set-PoshContext Set-PoshContext
$terminalWidth = $Host.UI.RawUI.WindowSize.Width $terminalWidth = $Host.UI.RawUI.WindowSize.Width
# set a sane default when the value can't be retrieved # set a sane default when the value can't be retrieved