@@ -99,32 +99,23 @@ export class TerminalService implements ITerminalService, Disposable {
9999
100100 if ( terminal . shellIntegration ) {
101101 const execution = terminal . shellIntegration . executeCommand ( commandLine ) ;
102- const result = await Promise . race ( [
103- new Promise < ITerminalExecutedCommand > ( ( resolve ) => {
104- const listener = this . terminalManager . onDidEndTerminalShellExecution ( ( e ) => {
102+
103+ let result = undefined ;
104+ let disposable : Disposable | undefined ;
105+ try {
106+ result = await new Promise < ITerminalExecutedCommand > ( ( resolve ) => {
107+ disposable = this . terminalManager . onDidEndTerminalShellExecution ( ( e ) => {
105108 if ( e . execution === execution ) {
106- this . executeCommandListeners . delete ( listener ) ;
107109 resolve ( { execution, exitCode : e . exitCode } ) ;
108110 }
109111 } ) ;
110- if ( listener ) {
111- this . executeCommandListeners . add ( listener ) ;
112- }
113- traceVerbose ( `Shell Integration is enabled, executeCommand: ${ commandLine } ` ) ;
114- } ) ,
115- new Promise < undefined > ( ( resolve ) => {
116- setTimeout ( ( ) => {
117- resolve ( undefined ) ;
118- } , 5000 ) ;
119- } ) ,
120- ] ) ;
121112
122- if ( result === undefined ) {
123- traceVerbose ( `Execution timed out, falling back to sendText: ${ commandLine } ` ) ;
124- terminal . sendText ( commandLine ) ;
125- return undefined ;
126- } else {
113+ traceVerbose ( `Shell Integration is enabled, executeCommand: ${ commandLine } ` ) ;
114+ } ) ;
127115 return result ;
116+ } catch {
117+ } finally {
118+ disposable ?. dispose ( ) ;
128119 }
129120 } else {
130121 terminal . sendText ( commandLine ) ;
@@ -148,7 +139,6 @@ export class TerminalService implements ITerminalService, Disposable {
148139 this . terminalShellType = this . terminalHelper . identifyTerminalShell ( this . terminal ) ;
149140 this . terminal = this . terminalManager . createTerminal ( {
150141 name : this . options ?. title || 'Python' ,
151- env : { } ,
152142 hideFromUser : this . options ?. hideFromUser ,
153143 } ) ;
154144 this . terminalAutoActivator . disableAutoActivation ( this . terminal ) ;
0 commit comments