@@ -31,11 +31,11 @@ export class TerminalService implements ITerminalService, Disposable {
3131 private terminalActivator : ITerminalActivator ;
3232 private terminalAutoActivator : ITerminalAutoActivation ;
3333 private readonly executeCommandListeners : Set < Disposable > = new Set ( ) ;
34+ private _shellIntegrationEnabled : boolean = false ;
3435 public get onDidCloseTerminal ( ) : Event < void > {
3536 return this . terminalClosed . event . bind ( this . terminalClosed ) ;
3637 }
3738
38- // private _shellIntegrationEnabled
3939 constructor (
4040 @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ,
4141 private readonly options ?: TerminalCreationOptions ,
@@ -81,15 +81,17 @@ export class TerminalService implements ITerminalService, Disposable {
8181 }
8282
8383 // If terminal was just launched, wait some time for shell integration to onDidChangeShellIntegration.
84- if ( ! terminal . shellIntegration ) {
84+ if ( ! terminal . shellIntegration && ! this . _shellIntegrationEnabled ) {
8585 const promise = new Promise < boolean > ( ( resolve ) => {
8686 const disposable = this . terminalManager . onDidChangeTerminalShellIntegration ( ( ) => {
87+ this . _shellIntegrationEnabled = true ;
8788 clearTimeout ( timer ) ; //racetimeout
8889 disposable . dispose ( ) ;
8990 resolve ( true ) ;
9091 } ) ;
9192 const TIMEOUT_DURATION = 500 ;
9293 const timer = setTimeout ( ( ) => {
94+ this . _shellIntegrationEnabled = false ;
9395 disposable . dispose ( ) ;
9496 resolve ( true ) ;
9597 } , TIMEOUT_DURATION ) ;
@@ -101,8 +103,10 @@ export class TerminalService implements ITerminalService, Disposable {
101103 // TODO: executeCommand would not execute command manually typed inside Python Terminal REPL.
102104 // We only run executeCommand when user shift+enter in .py file, and hence run command in terminal on user's behalf.
103105 const execution = terminal . shellIntegration . executeCommand ( commandLine ) ;
106+ this . _shellIntegrationEnabled = true ;
104107 return execution ;
105108 } else {
109+ this . _shellIntegrationEnabled = false ;
106110 terminal . sendText ( commandLine ) ;
107111 traceVerbose ( `Shell Integration is disabled, sendText: ${ commandLine } ` ) ;
108112 }
0 commit comments