Skip to content

Commit 2b883b5

Browse files
authored
Merge pull request #252429 from microsoft/tyriar/252300
Don't focus terminal on group dispose unless it was focused before
2 parents 8d05b57 + 19a9fdc commit 2b883b5

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export interface ITerminalGroup {
133133
activeInstance: ITerminalInstance | undefined;
134134
terminalInstances: ITerminalInstance[];
135135
title: string;
136+
readonly hadFocusOnExit: boolean;
136137

137138
readonly onDidDisposeInstance: Event<ITerminalInstance>;
138139
readonly onDisposed: Event<ITerminalGroup>;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ export class TerminalGroup extends Disposable implements ITerminalGroup {
251251

252252
get terminalInstances(): ITerminalInstance[] { return this._terminalInstances; }
253253

254+
private _hadFocusOnExit: boolean = false;
255+
get hadFocusOnExit(): boolean { return this._hadFocusOnExit; }
256+
254257
private _initialRelativeSizes: number[] | undefined;
255258
private _visible: boolean = false;
256259

@@ -395,6 +398,7 @@ export class TerminalGroup extends Disposable implements ITerminalGroup {
395398

396399
// Fire events and dispose group if it was the last instance
397400
if (this._terminalInstances.length === 0) {
401+
this._hadFocusOnExit = instance.hadFocusOnExit;
398402
this._onDisposed.fire(this);
399403
this.dispose();
400404
} else {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
218218
if (this.groups.length > 0 && !this._isQuickInputOpened) {
219219
const newIndex = index < this.groups.length ? index : this.groups.length - 1;
220220
this.setActiveGroupByIndex(newIndex, true);
221-
this.activeInstance?.focus(true);
221+
if (group.hadFocusOnExit) {
222+
this.activeInstance?.focus(true);
223+
}
222224
}
223225
} else {
224226
// Adjust the active group if the removed group was above the active group

0 commit comments

Comments
 (0)