Skip to content

Commit 09ab362

Browse files
fix(pwsh): correctly identify error scope
resolves #6312
1 parent f0b0fe9 commit 09ab362

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: src/shell/scripts/omp.ps1

+3-2
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
227227
}
228228
catch { $null }
229229

230-
# check if the last command caused the last error
231-
if ($null -ne $invocationInfo -and $lastHistory.CommandLine -eq $invocationInfo.Line) {
230+
# Check if the error occurred in the current command scope
231+
if ($null -ne $invocationInfo -and
232+
$invocationInfo.HistoryId -eq $lastHistory.Id) {
232233
$script:ErrorCode = 1
233234
return
234235
}

0 commit comments

Comments
 (0)