Skip to content

Commit 9a28101

Browse files
authored
Merge pull request microsoft#189204 from microsoft/tyriar/39137
Add hideOnStartup terminal setting
2 parents 101b288 + 6b8fd6a commit 9a28101

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/vs/platform/terminal/common/terminal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const enum TerminalSettingId {
9898
LocalEchoStyle = 'terminal.integrated.localEchoStyle',
9999
EnablePersistentSessions = 'terminal.integrated.enablePersistentSessions',
100100
PersistentSessionReviveProcess = 'terminal.integrated.persistentSessionReviveProcess',
101+
HideOnStartup = 'terminal.integrated.hideOnStartup',
101102
CustomGlyphs = 'terminal.integrated.customGlyphs',
102103
PersistentSessionScrollback = 'terminal.integrated.persistentSessionScrollback',
103104
InheritEnv = 'terminal.integrated.inheritEnv',

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class TerminalViewPane extends ViewPane {
5555
private _terminalTabbedView?: TerminalTabbedView;
5656
get terminalTabbedView(): TerminalTabbedView | undefined { return this._terminalTabbedView; }
5757
private _isWelcomeShowing: boolean = false;
58+
private _isInitialized: boolean = false;
5859
private _newDropdown: DropdownWithPrimaryActionViewItem | undefined;
5960
private readonly _dropdownMenu: IMenu;
6061
private readonly _singleTabMenu: IMenu;
@@ -131,15 +132,41 @@ export class TerminalViewPane extends ViewPane {
131132

132133
private _initializeTerminal(checkRestoredTerminals: boolean) {
133134
if (this.isBodyVisible() && this._terminalService.isProcessSupportRegistered && this._terminalService.connectionState === TerminalConnectionState.Connected) {
135+
const wasInitialized = this._isInitialized;
136+
this._isInitialized = true;
137+
138+
let hideOnStartup: 'never' | 'whenEmpty' | 'always' = 'never';
139+
if (!wasInitialized) {
140+
hideOnStartup = this._configurationService.getValue(TerminalSettingId.HideOnStartup);
141+
if (hideOnStartup === 'always') {
142+
this._terminalGroupService.hidePanel();
143+
}
144+
}
145+
134146
let shouldCreate = this._terminalGroupService.groups.length === 0;
135147
// When triggered just after reconnection, also check there are no groups that could be
136148
// getting restored currently
137149
if (checkRestoredTerminals) {
138150
shouldCreate &&= this._terminalService.restoredGroupCount === 0;
139151
}
140-
if (shouldCreate) {
141-
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
152+
if (!shouldCreate) {
153+
return;
142154
}
155+
if (!wasInitialized) {
156+
switch (hideOnStartup) {
157+
case 'never':
158+
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
159+
break;
160+
case 'whenEmpty':
161+
if (this._terminalService.restoredGroupCount === 0) {
162+
this._terminalGroupService.hidePanel();
163+
}
164+
break;
165+
}
166+
return;
167+
}
168+
169+
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
143170
}
144171
}
145172

src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,17 @@ const terminalConfiguration: IConfigurationNode = {
529529
],
530530
default: 'onExit'
531531
},
532+
[TerminalSettingId.HideOnStartup]: {
533+
description: localize('terminal.integrated.hideOnStartup', "Whether to hide the terminal view on startup, avoiding creating a terminal when there are no persistent sessions."),
534+
type: 'string',
535+
enum: ['never', 'whenEmpty', 'always'],
536+
markdownEnumDescriptions: [
537+
localize('hideOnStartup.never', "Never hide the terminal view on startup."),
538+
localize('hideOnStartup.whenEmpty', "Only hide the terminal when there are no persistent sessions restored."),
539+
localize('hideOnStartup.always', "Always hide the terminal, even when there are persistent sessions restored.")
540+
],
541+
default: 'never'
542+
},
532543
[TerminalSettingId.CustomGlyphs]: {
533544
description: localize('terminal.integrated.customGlyphs', "Whether to draw custom glyphs for block element and box drawing characters instead of using the font, which typically yields better rendering with continuous lines. Note that this doesn't work when {0} is disabled.", `\`#${TerminalSettingId.GpuAcceleration}#\``),
534545
type: 'boolean',

0 commit comments

Comments
 (0)