Unset active terminal group when last is removed

Part of #92649
This commit is contained in:
Daniel Imms 2021-07-07 07:44:57 -07:00
parent 36ed3acc40
commit 7d00e4e560

View file

@ -238,9 +238,22 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
* group has been removed.
*/
setActiveGroupByIndex(index: number, force?: boolean) {
// Unset active group when the last group is removed
if (index === -1 && this.groups.length === 0) {
if (this.activeGroupIndex !== -1) {
this.activeGroupIndex = -1;
this._onDidChangeActiveGroup.fire(this.activeGroup);
this._onDidChangeActiveInstance.fire(this.activeInstance);
}
return;
}
// Ensure index is valid
if (index < 0 || index >= this.groups.length) {
return;
}
// Fire group/instance change if needed
const oldActiveGroup = this.activeGroup;
this.activeGroupIndex = index;
if (force || oldActiveGroup !== this.activeGroup) {