Skip to content

Commit 268e9da

Browse files
authored
Merge pull request microsoft#128650 from microsoft/tyriar/r158_128255
Unset active terminal group when last is removed
2 parents d9e4111 + 35b634d commit 268e9da

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/vs/workbench/contrib/terminal/browser/terminalGroupService.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,22 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
238238
* group has been removed.
239239
*/
240240
setActiveGroupByIndex(index: number, force?: boolean) {
241+
// Unset active group when the last group is removed
242+
if (index === -1 && this.groups.length === 0) {
243+
if (this.activeGroupIndex !== -1) {
244+
this.activeGroupIndex = -1;
245+
this._onDidChangeActiveGroup.fire(this.activeGroup);
246+
this._onDidChangeActiveInstance.fire(this.activeInstance);
247+
}
248+
return;
249+
}
250+
251+
// Ensure index is valid
241252
if (index < 0 || index >= this.groups.length) {
242253
return;
243254
}
255+
256+
// Fire group/instance change if needed
244257
const oldActiveGroup = this.activeGroup;
245258
this.activeGroupIndex = index;
246259
if (force || oldActiveGroup !== this.activeGroup) {

0 commit comments

Comments
 (0)