mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix: wrong stack count when init from Set-PoshPrompt
This commit is contained in:
parent
b9601b632a
commit
4f96cc0f7c
|
@ -56,6 +56,11 @@ function Set-PoshPrompt {
|
||||||
$config = "$PSScriptRoot/themes/jandedobbeleer.omp.json"
|
$config = "$PSScriptRoot/themes/jandedobbeleer.omp.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Workaround for get-location/push-location/pop-location from within a module
|
||||||
|
# https://github.com/PowerShell/PowerShell/issues/12868
|
||||||
|
# https://github.com/JanDeDobbeleer/oh-my-posh2/issues/113
|
||||||
|
$global:omp_global_sessionstate = $PSCmdlet.SessionState
|
||||||
|
|
||||||
$poshCommand = Get-PoshCommand
|
$poshCommand = Get-PoshCommand
|
||||||
Invoke-Expression (& $poshCommand --init --shell=pwsh --config="$config")
|
Invoke-Expression (& $poshCommand --init --shell=pwsh --config="$config")
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,12 @@ function global:Initialize-ModuleSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$stackCount = (Get-Location -Stack).Count
|
$stackCount = 0
|
||||||
|
try {
|
||||||
|
$stackCount = ($global:omp_global_sessionstate).path.locationstack('').count
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
|
|
||||||
$executionTime = -1
|
$executionTime = -1
|
||||||
$history = Get-History -ErrorAction Ignore -Count 1
|
$history = Get-History -ErrorAction Ignore -Count 1
|
||||||
if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime -and $global:omp_lastHistoryId -ne $history.Id) {
|
if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime -and $global:omp_lastHistoryId -ne $history.Id) {
|
||||||
|
|
Loading…
Reference in a new issue