@@ -82,10 +82,7 @@ declare module "vscode" {
8282 // https://github.com/microsoft/vscode/blob/f0417069c62e20f3667506f4b7e53ca0004b4e3e/src/vscode-dts/vscode.d.ts#L10794
8383 interface Window {
8484 onDidStartTerminalShellExecution ?: (
85- listener : ( e : {
86- terminal : vscode . Terminal
87- execution : { read ( ) : AsyncIterable < string > ; commandLine : { value : string } }
88- } ) => any ,
85+ listener : ( e : any ) => any ,
8986 thisArgs ?: any ,
9087 disposables ?: vscode . Disposable [ ] ,
9188 ) => vscode . Disposable
@@ -206,77 +203,57 @@ export class TerminalManager {
206203 constructor ( ) {
207204 let startDisposable : vscode . Disposable | undefined
208205 let endDisposable : vscode . Disposable | undefined
209-
210206 try {
211207 // onDidStartTerminalShellExecution
212208 startDisposable = ( vscode . window as vscode . Window ) . onDidStartTerminalShellExecution ?.( async ( e ) => {
213209 // Get a handle to the stream as early as possible:
214210 const stream = e ?. execution . read ( )
215211 const terminalInfo = TerminalRegistry . getTerminalInfoByTerminal ( e . terminal )
216-
217- console . info ( "[TerminalManager] shell execution started" , {
218- hasExecution : ! ! e ?. execution ,
219- hasStream : ! ! stream ,
220- command : e ?. execution ?. commandLine ?. value ,
221- terminalId : terminalInfo ?. id ,
222- } )
223-
224- if ( terminalInfo ) {
212+ if ( stream && terminalInfo ) {
225213 const process = this . processes . get ( terminalInfo . id )
226-
227214 if ( process ) {
228- if ( stream ) {
229- terminalInfo . stream = stream
230- terminalInfo . running = true
231- terminalInfo . streamClosed = false
232- console . log ( `[TerminalManager] stream_available -> ${ terminalInfo . id } ` )
233- process . emit ( "stream_available" , terminalInfo . id , stream )
234- } else {
235- process . emit ( "stream_unavailable" , terminalInfo . id )
236- console . error ( `[TerminalManager] stream_unavailable -> ${ terminalInfo . id } ` )
237- }
215+ terminalInfo . stream = stream
216+ terminalInfo . running = true
217+ terminalInfo . streamClosed = false
218+ process . emit ( "stream_available" , terminalInfo . id , stream )
238219 }
239220 } else {
240- console . error ( "[TerminalManager] terminalInfo not available " )
221+ console . error ( "[TerminalManager] Stream failed, not registered for terminal " )
241222 }
223+
224+ console . info ( "[TerminalManager] Shell execution started:" , {
225+ hasExecution : ! ! e ?. execution ,
226+ command : e ?. execution ?. commandLine ?. value ,
227+ terminalId : terminalInfo ?. id ,
228+ } )
242229 } )
243230
244231 // onDidEndTerminalShellExecution
245232 endDisposable = ( vscode . window as vscode . Window ) . onDidEndTerminalShellExecution ?.( async ( e ) => {
246233 const exitDetails = this . interpretExitCode ( e ?. exitCode )
247- console . info ( "[TerminalManager] Shell execution ended:" , { ...exitDetails } )
248- let emitted = false
234+ console . info ( "[TerminalManager] Shell execution ended:" , {
235+ ...exitDetails ,
236+ } )
249237
250- // Signal completion to any waiting processes.
238+ // Signal completion to any waiting processes
251239 for ( const id of this . terminalIds ) {
252240 const info = TerminalRegistry . getTerminal ( id )
253-
254241 if ( info && info . terminal === e . terminal ) {
255242 info . running = false
256243 const process = this . processes . get ( id )
257-
258244 if ( process ) {
259- console . log ( `[TerminalManager] emitting shell_execution_complete -> ${ id } ` )
260- emitted = true
261245 process . emit ( "shell_execution_complete" , id , exitDetails )
262246 }
263-
264247 break
265248 }
266249 }
267-
268- if ( ! emitted ) {
269- console . log ( `[TerminalManager#onDidStartTerminalShellExecution] no terminal found` )
270- }
271250 } )
272251 } catch ( error ) {
273- console . error ( "[TerminalManager] failed to configure shell execution handlers" , error )
252+ console . error ( "[TerminalManager] Error setting up shell execution handlers: " , error )
274253 }
275-
276254 if ( startDisposable ) {
277255 this . disposables . push ( startDisposable )
278256 }
279-
280257 if ( endDisposable ) {
281258 this . disposables . push ( endDisposable )
282259 }
@@ -389,6 +366,9 @@ export class TerminalManager {
389366 }
390367
391368 disposeAll ( ) {
369+ // for (const info of this.terminals) {
370+ // //info.terminal.dispose() // dont want to dispose terminals when task is aborted
371+ // }
392372 this . terminalIds . clear ( )
393373 this . processes . clear ( )
394374 this . disposables . forEach ( ( disposable ) => disposable . dispose ( ) )
0 commit comments