Merge pull request #187870 from microsoft/tyriar/187772

Always create terminal on empty terminal view show
This commit is contained in:
Daniel Imms
2023-07-13 14:43:36 -07:00
committed by GitHub
@@ -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);
}