Skip to content

Commit 9ed8c26

Browse files
committed
Always create terminal on empty terminal view show
Part of microsoft#187772
1 parent 74f6148 commit 9ed8c26

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,17 @@ export class TerminalViewPane extends ViewPane {
125125
return (decorationsEnabled === 'both' || decorationsEnabled === 'gutter') && this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled);
126126
}
127127

128-
private _initializeTerminal() {
129-
if (this.isBodyVisible() && this._terminalService.isProcessSupportRegistered && this._terminalService.connectionState === TerminalConnectionState.Connected && this._terminalService.restoredGroupCount === 0 && this._terminalGroupService.groups.length === 0) {
130-
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
128+
private _initializeTerminal(checkRestoredTerminals: boolean) {
129+
if (this.isBodyVisible() && this._terminalService.isProcessSupportRegistered && this._terminalService.connectionState === TerminalConnectionState.Connected) {
130+
let shouldCreate = this._terminalGroupService.groups.length === 0;
131+
// When triggered just after reconnection, also check there are no groups that could be
132+
// getting restored currently
133+
if (checkRestoredTerminals) {
134+
shouldCreate &&= this._terminalService.restoredGroupCount === 0;
135+
}
136+
if (shouldCreate) {
137+
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
138+
}
131139
}
132140
}
133141

@@ -167,7 +175,7 @@ export class TerminalViewPane extends ViewPane {
167175
if (!this._terminalService.isProcessSupportRegistered) {
168176
this._onDidChangeViewWelcomeState.fire();
169177
}
170-
this._initializeTerminal();
178+
this._initializeTerminal(false);
171179
// we don't know here whether or not it should be focused, so
172180
// defer focusing the panel to the focus() call
173181
// to prevent overriding preserveFocus for extensions
@@ -179,7 +187,7 @@ export class TerminalViewPane extends ViewPane {
179187
}
180188
this._terminalGroupService.updateVisibility();
181189
}));
182-
this._register(this._terminalService.onDidChangeConnectionState(() => this._initializeTerminal()));
190+
this._register(this._terminalService.onDidChangeConnectionState(() => this._initializeTerminal(true)));
183191
this.layoutBody(this._parentDomElement.offsetHeight, this._parentDomElement.offsetWidth);
184192
}
185193

0 commit comments

Comments
 (0)