@@ -23,14 +23,14 @@ export class TerminalService implements ITerminalService {
2323 private _activeTerminalInstanceIndex : number = 0 ;
2424 private _configHelper : TerminalConfigHelper ;
2525 private _onActiveInstanceChanged : Emitter < string > ;
26- private _onInstanceClosed : Emitter < ITerminalInstance > ;
26+ private _onInstanceDisposed : Emitter < ITerminalInstance > ;
2727 private _onInstanceTitleChanged : Emitter < string > ;
2828 private _onInstancesChanged : Emitter < string > ;
2929 private _terminalInstances : ITerminalInstance [ ] = [ ] ;
3030 public get activeTerminalInstanceIndex ( ) : number { return this . _activeTerminalInstanceIndex ; }
3131 public get configHelper ( ) : TerminalConfigHelper { return this . _configHelper ; }
3232 public get onActiveInstanceChanged ( ) : Event < string > { return this . _onActiveInstanceChanged . event ; }
33- public get onInstanceClosed ( ) : Event < ITerminalInstance > { return this . _onInstanceClosed . event ; }
33+ public get onInstanceDisposed ( ) : Event < ITerminalInstance > { return this . _onInstanceDisposed . event ; }
3434 public get onInstanceTitleChanged ( ) : Event < string > { return this . _onInstanceTitleChanged . event ; }
3535 public get onInstancesChanged ( ) : Event < string > { return this . _onInstancesChanged . event ; }
3636 public get terminalInstances ( ) : ITerminalInstance [ ] { return this . _terminalInstances ; }
@@ -47,11 +47,12 @@ export class TerminalService implements ITerminalService {
4747 @IWorkspaceContextService private workspaceContextService : IWorkspaceContextService
4848 ) {
4949 this . _onActiveInstanceChanged = new Emitter < string > ( ) ;
50- this . _onInstanceClosed = new Emitter < ITerminalInstance > ( ) ;
50+ this . _onInstanceDisposed = new Emitter < ITerminalInstance > ( ) ;
5151 this . _onInstancesChanged = new Emitter < string > ( ) ;
5252 this . _onInstanceTitleChanged = new Emitter < string > ( ) ;
5353 this . terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS . bindTo ( this . contextKeyService ) ;
5454 this . _configHelper = < TerminalConfigHelper > this . instantiationService . createInstance ( TerminalConfigHelper , platform . platform ) ;
55+ this . onInstanceDisposed ( ( terminalInstance ) => { this . removeInstance ( terminalInstance ) ; } ) ;
5556 }
5657
5758 public createInstance ( name ?: string , shellPath ?: string , shellArgs ?: string [ ] ) : ITerminalInstance {
@@ -61,14 +62,13 @@ export class TerminalService implements ITerminalService {
6162 } ;
6263 let terminalInstance = < TerminalInstance > this . instantiationService . createInstance ( TerminalInstance ,
6364 this . terminalFocusContextKey ,
64- this . onTerminalInstanceDispose . bind ( this ) ,
6565 this . _configHelper ,
6666 this . terminalContainer ,
6767 this . workspaceContextService . getWorkspace ( ) ,
6868 name ,
6969 shell ) ;
7070 terminalInstance . addDisposable ( terminalInstance . onTitleChanged ( this . _onInstanceTitleChanged . fire , this . _onInstanceTitleChanged ) ) ;
71- terminalInstance . addDisposable ( terminalInstance . onClosed ( this . _onInstanceClosed . fire , this . _onInstanceClosed ) ) ;
71+ terminalInstance . addDisposable ( terminalInstance . onClosed ( this . _onInstanceDisposed . fire , this . _onInstanceDisposed ) ) ;
7272 this . terminalInstances . push ( terminalInstance ) ;
7373 if ( this . terminalInstances . length === 1 ) {
7474 // It's the first instance so it should be made active automatically
@@ -82,7 +82,7 @@ export class TerminalService implements ITerminalService {
8282 return this . _terminalInstances . map ( ( instance , index ) => `${ index + 1 } : ${ instance . title } ` ) ;
8383 }
8484
85- private onTerminalInstanceDispose ( terminalInstance : TerminalInstance ) : void {
85+ private removeInstance ( terminalInstance : ITerminalInstance ) : void {
8686 let index = this . terminalInstances . indexOf ( terminalInstance ) ;
8787 let wasActiveInstance = terminalInstance === this . getActiveInstance ( ) ;
8888 if ( index !== - 1 ) {
0 commit comments