Skip to content

Commit 24d2c1b

Browse files
Add integratedConsole.startInBackground to completely hide the terminal (#4152)
This makes hiding the Extension Terminal from the set of terminals in VS Code an option, with a big warning that most users are probably just looking for `showOnStartup`, and that if enabled, to access the terminal you must manually open it some other way (such as with `Show Extension Terminal`). Some users require this as part of their workflow.
1 parent 8ac3309 commit 24d2c1b

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,12 @@
772772
"powershell.integratedConsole.showOnStartup": {
773773
"type": "boolean",
774774
"default": true,
775-
"description": "Shows the Extension Terminal when the PowerShell extension is initialized."
775+
"description": "Shows the Extension Terminal when the PowerShell extension is initialized. When disabled, the pane is not opened on startup, but the Extension Terminal is still created in order to power the extension's features."
776+
},
777+
"powershell.integratedConsole.startInBackground": {
778+
"type": "boolean",
779+
"default": false,
780+
"description": "Starts the Extension Terminal in the background. WARNING: If this is enabled, to access the terminal you must run the 'Show Extension Terminal' command, and once shown it cannot be put back into the background. This option completely hides the Extension Terminal from the terminals pane. You are probably looking for the 'showOnStartup' option instead."
776781
},
777782
"powershell.integratedConsole.focusConsoleOnExecute": {
778783
"type": "boolean",

src/process.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,16 @@ export class PowerShellProcess {
112112
cwd: this.sessionSettings.cwd,
113113
iconPath: new vscode.ThemeIcon("terminal-powershell"),
114114
isTransient: true,
115+
hideFromUser: this.sessionSettings.integratedConsole.startInBackground,
115116
};
116117

117118
this.consoleTerminal = vscode.window.createTerminal(terminalOptions);
118119

119120
const pwshName = path.basename(this.exePath);
120121
this.log.write(`${pwshName} started.`);
121122

122-
if (this.sessionSettings.integratedConsole.showOnStartup) {
123+
if (this.sessionSettings.integratedConsole.showOnStartup
124+
&& !this.sessionSettings.integratedConsole.startInBackground) {
123125
// We still need to run this to set the active terminal to the extension terminal.
124126
this.consoleTerminal.show(true);
125127
}

src/session.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,12 @@ Type 'help' to get help.
462462

463463
// Detect any setting changes that would affect the session
464464
if (!this.suppressRestartPrompt &&
465-
(settings.cwd?.toLowerCase() !==
466-
this.sessionSettings.cwd?.toLowerCase() ||
467-
settings.powerShellDefaultVersion.toLowerCase() !==
468-
this.sessionSettings.powerShellDefaultVersion.toLowerCase() ||
469-
settings.developer.editorServicesLogLevel.toLowerCase() !==
470-
this.sessionSettings.developer.editorServicesLogLevel.toLowerCase() ||
471-
settings.developer.bundledModulesPath.toLowerCase() !==
472-
this.sessionSettings.developer.bundledModulesPath.toLowerCase() ||
473-
settings.integratedConsole.useLegacyReadLine !==
474-
this.sessionSettings.integratedConsole.useLegacyReadLine)) {
475-
465+
(settings.cwd?.toLowerCase() !== this.sessionSettings.cwd?.toLowerCase()
466+
|| settings.powerShellDefaultVersion.toLowerCase() !== this.sessionSettings.powerShellDefaultVersion.toLowerCase()
467+
|| settings.developer.editorServicesLogLevel.toLowerCase() !== this.sessionSettings.developer.editorServicesLogLevel.toLowerCase()
468+
|| settings.developer.bundledModulesPath.toLowerCase() !== this.sessionSettings.developer.bundledModulesPath.toLowerCase()
469+
|| settings.integratedConsole.useLegacyReadLine !== this.sessionSettings.integratedConsole.useLegacyReadLine
470+
|| settings.integratedConsole.startInBackground !== this.sessionSettings.integratedConsole.startInBackground)) {
476471
const response: string = await vscode.window.showInformationMessage(
477472
"The PowerShell runtime configuration has changed, would you like to start a new session?",
478473
"Yes", "No");

src/settings.ts

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export interface IStartAsLoginShellSettings {
110110

111111
export interface IIntegratedConsoleSettings {
112112
showOnStartup?: boolean;
113+
startInBackground?: boolean;
113114
focusConsoleOnExecute?: boolean;
114115
useLegacyReadLine?: boolean;
115116
forceClearScrollbackBuffer?: boolean;
@@ -196,6 +197,7 @@ export function load(): ISettings {
196197

197198
const defaultIntegratedConsoleSettings: IIntegratedConsoleSettings = {
198199
showOnStartup: true,
200+
startInBackground: false,
199201
focusConsoleOnExecute: true,
200202
useLegacyReadLine: false,
201203
forceClearScrollbackBuffer: false,

0 commit comments

Comments
 (0)