Skip to content

Commit

Permalink
Add hideOnStartup terminal setting
Browse files Browse the repository at this point in the history
Fixes #39137
  • Loading branch information
Tyriar committed Jul 29, 2023
1 parent 101b288 commit 6b8fd6a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const enum TerminalSettingId {
LocalEchoStyle = 'terminal.integrated.localEchoStyle',
EnablePersistentSessions = 'terminal.integrated.enablePersistentSessions',
PersistentSessionReviveProcess = 'terminal.integrated.persistentSessionReviveProcess',
HideOnStartup = 'terminal.integrated.hideOnStartup',
CustomGlyphs = 'terminal.integrated.customGlyphs',
PersistentSessionScrollback = 'terminal.integrated.persistentSessionScrollback',
InheritEnv = 'terminal.integrated.inheritEnv',
Expand Down
31 changes: 29 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminalView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class TerminalViewPane extends ViewPane {
private _terminalTabbedView?: TerminalTabbedView;
get terminalTabbedView(): TerminalTabbedView | undefined { return this._terminalTabbedView; }
private _isWelcomeShowing: boolean = false;
private _isInitialized: boolean = false;
private _newDropdown: DropdownWithPrimaryActionViewItem | undefined;
private readonly _dropdownMenu: IMenu;
private readonly _singleTabMenu: IMenu;
Expand Down Expand Up @@ -131,15 +132,41 @@ export class TerminalViewPane extends ViewPane {

private _initializeTerminal(checkRestoredTerminals: boolean) {
if (this.isBodyVisible() && this._terminalService.isProcessSupportRegistered && this._terminalService.connectionState === TerminalConnectionState.Connected) {
const wasInitialized = this._isInitialized;
this._isInitialized = true;

let hideOnStartup: 'never' | 'whenEmpty' | 'always' = 'never';
if (!wasInitialized) {
hideOnStartup = this._configurationService.getValue(TerminalSettingId.HideOnStartup);
if (hideOnStartup === 'always') {
this._terminalGroupService.hidePanel();
}
}

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 });
if (!shouldCreate) {
return;
}
if (!wasInitialized) {
switch (hideOnStartup) {
case 'never':
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
break;
case 'whenEmpty':
if (this._terminalService.restoredGroupCount === 0) {
this._terminalGroupService.hidePanel();
}
break;
}
return;
}

this._terminalService.createTerminal({ location: TerminalLocation.Panel });
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,17 @@ const terminalConfiguration: IConfigurationNode = {
],
default: 'onExit'
},
[TerminalSettingId.HideOnStartup]: {
description: localize('terminal.integrated.hideOnStartup', "Whether to hide the terminal view on startup, avoiding creating a terminal when there are no persistent sessions."),
type: 'string',
enum: ['never', 'whenEmpty', 'always'],
markdownEnumDescriptions: [
localize('hideOnStartup.never', "Never hide the terminal view on startup."),
localize('hideOnStartup.whenEmpty', "Only hide the terminal when there are no persistent sessions restored."),
localize('hideOnStartup.always', "Always hide the terminal, even when there are persistent sessions restored.")
],
default: 'never'
},
[TerminalSettingId.CustomGlyphs]: {
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}#\``),
type: 'boolean',
Expand Down

0 comments on commit 6b8fd6a

Please sign in to comment.