Skip to content

Commit 30c8810

Browse files
committed
Use BASH_COMMAND instead of history for empty command detection
Part of microsoft#143766
1 parent e5f5a16 commit 30c8810

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ if [[ "$PROMPT_COMMAND" =~ .*(' '.*\;)|(\;.*' ').* ]]; then
3939
builtin return
4040
fi
4141

42-
# Disable shell integration if HISTCONTROL is set to erase duplicate entries as the exit code
43-
# reporting relies on the duplicates existing
44-
if [[ "$HISTCONTROL" =~ .*erasedups.* ]]; then
45-
builtin unset VSCODE_SHELL_INTEGRATION
46-
builtin return
47-
fi
48-
4942
if [ -z "$VSCODE_SHELL_INTEGRATION" ]; then
5043
builtin return
5144
fi
@@ -56,7 +49,7 @@ __vsc_original_PS2="$PS2"
5649
__vsc_custom_PS1=""
5750
__vsc_custom_PS2=""
5851
__vsc_in_command_execution="1"
59-
__vsc_last_history_id=$(history 1 | awk '{print $1;}')
52+
__vsc_current_command=""
6053

6154
__vsc_prompt_start() {
6255
builtin printf "\033]633;A\007"
@@ -72,6 +65,13 @@ __vsc_update_cwd() {
7265

7366
__vsc_command_output_start() {
7467
builtin printf "\033]633;C\007"
68+
if [[ ! "$BASH_COMMAND" =~ ^__vsc_prompt* ]]; then
69+
__vsc_current_command=$BASH_COMMAND
70+
builtin printf "\033]633;E;$BASH_COMMAND\007"
71+
else
72+
__vsc_current_command=""
73+
builtin printf "\033]633;E\007"
74+
fi
7575
}
7676

7777
__vsc_continuation_start() {
@@ -83,12 +83,10 @@ __vsc_continuation_end() {
8383
}
8484

8585
__vsc_command_complete() {
86-
local __vsc_history_id=$(builtin history 1 | awk '{print $1;}')
87-
if [[ "$__vsc_history_id" == "$__vsc_last_history_id" ]]; then
86+
if [ "$__vsc_current_command" = "" ]; then
8887
builtin printf "\033]633;D\007"
8988
else
9089
builtin printf "\033]633;D;%s\007" "$__vsc_status"
91-
__vsc_last_history_id=$__vsc_history_id
9290
fi
9391
__vsc_update_cwd
9492
}

0 commit comments

Comments
 (0)