[terminal] IDEA-345156 Fix showing all commands as an error after failed application command

Previously we relied on the `LastExitCode`. This variable is updated when the external application is finished with its exit code. But this value is persisted during the execution of other internal terminal commands (powershell cmdlets and functions, for example). So as a result, we have taken it into account during the calculation of the exit code for the current command while it is outdated. Do not use it at all for now, because `$?` variable is enough now.

GitOrigin-RevId: ea40305f9f0bac92351b33627f2da22433363879
This commit is contained in:
Konstantin Hudyakov
2024-02-05 18:28:22 +02:00
committed by intellij-monorepo-bot
parent 750b32d236
commit 690bd4036d

View File

@@ -30,7 +30,6 @@ $Global:__JetBrainsIntellijGeneratorRunning=$false
function Global:Prompt() {
$Success = $?
$ExitCode = $Global:LastExitCode
if ($Global:__JetBrainsIntellijGeneratorRunning) {
$Global:__JetBrainsIntellijGeneratorRunning = $false
# Hide internal command in the built-in session history.
@@ -45,12 +44,7 @@ function Global:Prompt() {
$CommandEndMarker = Global:__JetBrainsIntellijGetCommandEndMarker
$PromptStateOSC = Global:__JetBrainsIntellijCreatePromptStateOSC
if ($__JetBrainsIntellijTerminalInitialized) {
if ($ExitCode -eq $null) {
$ExitCode = "0"
}
if (-not $Success -and $ExitCode -eq "0") {
$ExitCode = "1"
}
$ExitCode = if ($Success) { "0" } else { "1" }
if ($Env:JETBRAINS_INTELLIJ_TERMINAL_DEBUG_LOG_LEVEL) {
[Console]::WriteLine("command_finished exit_code=$ExitCode")
}