Skip to content

Commit

Permalink
Force group change event when active is removed
Browse files Browse the repository at this point in the history
Fixes #127308
  • Loading branch information
Tyriar committed Jun 28, 2021
1 parent e1a8566 commit ec932f3
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
// Adjust focus if the group was active
if (wasActiveGroup && this.groups.length > 0) {
const newIndex = index < this.groups.length ? index : this.groups.length - 1;
this.setActiveGroupByIndex(newIndex);
this.setActiveGroupByIndex(newIndex, true);
this.activeInstance?.focus(true);
} else if (this.activeGroupIndex >= this.groups.length) {
const newIndex = this.groups.length - 1;
Expand All @@ -243,13 +243,17 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
}
}

setActiveGroupByIndex(index: number) {
/**
* @param force Whether to force the group change, this should be used when the previous active
* group has been removed.
*/
setActiveGroupByIndex(index: number, force?: boolean) {
if (index >= this.groups.length) {
return;
}
const oldActiveGroup = this.activeGroup;
this.activeGroupIndex = index;
if (oldActiveGroup !== this.activeGroup) {
if (force || oldActiveGroup !== this.activeGroup) {
this.groups.forEach((g, i) => g.setVisible(i === this.activeGroupIndex));
this._onDidChangeActiveGroup.fire(this.activeGroup);
this._onDidChangeActiveInstance.fire(this.activeInstance);
Expand Down

0 comments on commit ec932f3

Please sign in to comment.