From 3dc85381366cf2425910b07693c3c807b21030ca Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Wed, 7 Dec 2022 19:36:08 +0800 Subject: [PATCH] feat(pwsh): make it compatible with NVS auto-switching --- src/shell/scripts/omp.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/shell/scripts/omp.ps1 b/src/shell/scripts/omp.ps1 index 24d16aeb..faf63d7c 100644 --- a/src/shell/scripts/omp.ps1 +++ b/src/shell/scripts/omp.ps1 @@ -331,8 +331,14 @@ Example: } function prompt { - # store the orignal last command execution status and last exit code - $script:OriginalLastExecutionStatus = $? + # store the orignal last command execution status + if ($global:NVS_ORIGINAL_LASTEXECUTIONSTATUS -is [bool]) { + # make it compatible with NVS auto-switching, if enabled + $script:OriginalLastExecutionStatus = $global:NVS_ORIGINAL_LASTEXECUTIONSTATUS + } else { + $script:OriginalLastExecutionStatus = $? + } + # store the orignal last exit code $script:OriginalLastExitCode = $global:LASTEXITCODE Set-PoshPromptType