@@ -16,6 +16,7 @@ if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") {
16
16
$Global :__VSCodeOriginalPrompt = $function: Prompt
17
17
18
18
$Global :__LastHistoryId = -1
19
+ $Global :__VSCodeIsInExecution = $false
19
20
20
21
# Store the nonce in script scope and unset the global
21
22
$Nonce = $env: VSCODE_NONCE
@@ -73,8 +74,10 @@ function Global:Prompt() {
73
74
Set-StrictMode - Off
74
75
$LastHistoryEntry = Get-History - Count 1
75
76
$Result = " "
76
- # Skip finishing the command if the first command has not yet started
77
- if ($Global :__LastHistoryId -ne -1 ) {
77
+ # Skip finishing the command if the first command has not yet started or an execution has not
78
+ # yet begun
79
+ if ($Global :__LastHistoryId -ne -1 -and $Global :__VSCodeIsInExecution -eq $true ) {
80
+ $Global :__VSCodeIsInExecution = $false
78
81
if ($LastHistoryEntry.Id -eq $Global :__LastHistoryId ) {
79
82
# Don't provide a command line or exit code if there was no history entry (eg. ctrl+c, enter on no command)
80
83
$Result += " $ ( [char ]0x1b ) ]633;D`a "
@@ -124,10 +127,10 @@ function Global:Prompt() {
124
127
# Only send the command executed sequence when PSReadLine is loaded, if not shell integration should
125
128
# still work thanks to the command line sequence
126
129
if (Get-Module - Name PSReadLine) {
127
- [Console ]::Write(" $ ( [char ]0x1b ) ]633;P;HasRichCommandDetection=True`a " )
128
130
$__VSCodeOriginalPSConsoleHostReadLine = $function: PSConsoleHostReadLine
129
131
function Global :PSConsoleHostReadLine {
130
132
$CommandLine = $__VSCodeOriginalPSConsoleHostReadLine.Invoke ()
133
+ $Global :__VSCodeIsInExecution = $true
131
134
132
135
# Command line
133
136
# OSC 633 ; E [; <CommandLine> [; <Nonce>]] ST
0 commit comments