@@ -28,7 +28,6 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
28
28
get instances ( ) : ITerminalInstance [ ] {
29
29
return this . groups . reduce ( ( p , c ) => p . concat ( c . terminalInstances ) , [ ] as ITerminalInstance [ ] ) ;
30
30
}
31
- activeInstanceIndex : number = - 1 ;
32
31
33
32
private _terminalGroupCountContextKey : IContextKey < number > ;
34
33
private _terminalCountContextKey : IContextKey < number > ;
@@ -105,10 +104,11 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
105
104
}
106
105
set activeGroup ( value : ITerminalGroup | undefined ) {
107
106
if ( value === undefined ) {
108
- this . activeGroupIndex = - 1 ;
107
+ // Setting to undefined is not possible, this can only be done when removing the last group
109
108
return ;
110
109
}
111
- this . activeGroupIndex = this . groups . findIndex ( e => e === value ) ;
110
+ const index = this . groups . findIndex ( e => e === value ) ;
111
+ this . setActiveGroupByIndex ( index ) ;
112
112
}
113
113
114
114
get activeInstance ( ) : ITerminalInstance | undefined {
@@ -233,13 +233,10 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
233
233
}
234
234
235
235
this . _onDidChangeInstances . fire ( ) ;
236
- if ( this . groups . length === 0 ) {
237
- this . _onDidChangeActiveInstance . fire ( undefined ) ;
238
- }
239
-
240
236
this . _onDidChangeGroups . fire ( ) ;
241
237
if ( wasActiveGroup ) {
242
238
this . _onDidChangeActiveGroup . fire ( this . activeGroup ) ;
239
+ this . _onDidChangeActiveInstance . fire ( this . activeInstance ) ;
243
240
}
244
241
}
245
242
@@ -248,7 +245,7 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
248
245
* group has been removed.
249
246
*/
250
247
setActiveGroupByIndex ( index : number , force ?: boolean ) {
251
- if ( index >= this . groups . length ) {
248
+ if ( index < 0 || index >= this . groups . length ) {
252
249
return ;
253
250
}
254
251
const oldActiveGroup = this . activeGroup ;
@@ -287,16 +284,15 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
287
284
return ;
288
285
}
289
286
290
- this . activeInstanceIndex = instanceLocation . instanceIndex ;
287
+ const activeInstanceIndex = instanceLocation . instanceIndex ;
291
288
292
289
if ( this . activeGroupIndex !== instanceLocation . groupIndex ) {
293
290
this . activeGroupIndex = instanceLocation . groupIndex ;
294
291
this . _onDidChangeActiveGroup . fire ( this . activeGroup ) ;
292
+ instanceLocation . group . setActiveInstanceByIndex ( activeInstanceIndex , true ) ;
295
293
}
296
294
this . groups . forEach ( ( g , i ) => g . setVisible ( i === instanceLocation . groupIndex ) ) ;
297
295
298
- instanceLocation . group . setActiveInstanceByIndex ( this . activeInstanceIndex ) ;
299
- this . _onDidChangeActiveInstance . fire ( newActiveInstance ) ;
300
296
}
301
297
302
298
setActiveGroupToNext ( ) {
0 commit comments