From 7b17343101821bd36e9939557e2200edc8122882 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:46:42 -0700 Subject: [PATCH] Always create terminal on empty terminal view show Part of #187772 --- .../contrib/terminal/browser/terminalView.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalView.ts b/src/vs/workbench/contrib/terminal/browser/terminalView.ts index c5b3308b7d4..f91f800c2ad 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalView.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalView.ts @@ -127,9 +127,17 @@ export class TerminalViewPane extends ViewPane { return (decorationsEnabled === 'both' || decorationsEnabled === 'gutter') && this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled); } - private _initializeTerminal() { - if (this.isBodyVisible() && this._terminalService.isProcessSupportRegistered && this._terminalService.connectionState === TerminalConnectionState.Connected && this._terminalService.restoredGroupCount === 0 && this._terminalGroupService.groups.length === 0) { - this._terminalService.createTerminal({ location: TerminalLocation.Panel }); + private _initializeTerminal(checkRestoredTerminals: boolean) { + if (this.isBodyVisible() && this._terminalService.isProcessSupportRegistered && this._terminalService.connectionState === TerminalConnectionState.Connected) { + let shouldCreate = this._terminalGroupService.groups.length === 0; + // When triggered just after reconnection, also check there are no groups that could be + // getting restored currently + if (checkRestoredTerminals) { + shouldCreate &&= this._terminalService.restoredGroupCount === 0; + } + if (shouldCreate) { + this._terminalService.createTerminal({ location: TerminalLocation.Panel }); + } } } @@ -169,7 +177,7 @@ export class TerminalViewPane extends ViewPane { if (!this._terminalService.isProcessSupportRegistered) { this._onDidChangeViewWelcomeState.fire(); } - this._initializeTerminal(); + this._initializeTerminal(false); // we don't know here whether or not it should be focused, so // defer focusing the panel to the focus() call // to prevent overriding preserveFocus for extensions @@ -181,7 +189,7 @@ export class TerminalViewPane extends ViewPane { } this._terminalGroupService.updateVisibility(); })); - this._register(this._terminalService.onDidChangeConnectionState(() => this._initializeTerminal())); + this._register(this._terminalService.onDidChangeConnectionState(() => this._initializeTerminal(true))); this.layoutBody(this._parentDomElement.offsetHeight, this._parentDomElement.offsetWidth); }