Ensure pwsh exit code is evaluated asap to fix failed commands

This commit is contained in:
Daniel Imms 2022-02-14 14:31:51 -08:00
parent cd636b4520
commit 007389a19e

View file

@ -21,6 +21,7 @@ function Global:__VSCode-Get-LastExitCode {
}
function Global:Prompt() {
$LastExitCode = $(__VSCode-Get-LastExitCode);
$LastHistoryEntry = $(Get-History -Count 1)
if ($LastHistoryEntry.Id -eq $Global:__LastHistoryId) {
# Don't provide a command line or exit code if there was no history entry (eg. ctrl+c, enter on no command)
@ -38,7 +39,7 @@ function Global:Prompt() {
$Result += "`a"
# Command finished exit code
# OSC 633 ; D [; <ExitCode>] ST
$Result += "`e]633;D;$(__VSCode-Get-LastExitCode)`a"
$Result += "`e]633;D;$LastExitCode`a"
}
# Prompt started
# OSC 633 ; A ST