Skip to content

Add integratedConsole.startInBackground to completely hide the terminal #4152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,12 @@
"powershell.integratedConsole.showOnStartup": {
"type": "boolean",
"default": true,
"description": "Shows the Extension Terminal when the PowerShell extension is initialized."
"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."
},
"powershell.integratedConsole.startInBackground": {
"type": "boolean",
"default": false,
"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."
},
"powershell.integratedConsole.focusConsoleOnExecute": {
"type": "boolean",
Expand Down
4 changes: 3 additions & 1 deletion src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,16 @@ export class PowerShellProcess {
cwd: this.sessionSettings.cwd,
iconPath: new vscode.ThemeIcon("terminal-powershell"),
isTransient: true,
hideFromUser: this.sessionSettings.integratedConsole.startInBackground,
};

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

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

if (this.sessionSettings.integratedConsole.showOnStartup) {
if (this.sessionSettings.integratedConsole.showOnStartup
&& !this.sessionSettings.integratedConsole.startInBackground) {
// We still need to run this to set the active terminal to the extension terminal.
this.consoleTerminal.show(true);
}
Expand Down
17 changes: 6 additions & 11 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,12 @@ Type 'help' to get help.

// Detect any setting changes that would affect the session
if (!this.suppressRestartPrompt &&
(settings.cwd?.toLowerCase() !==
this.sessionSettings.cwd?.toLowerCase() ||
settings.powerShellDefaultVersion.toLowerCase() !==
this.sessionSettings.powerShellDefaultVersion.toLowerCase() ||
settings.developer.editorServicesLogLevel.toLowerCase() !==
this.sessionSettings.developer.editorServicesLogLevel.toLowerCase() ||
settings.developer.bundledModulesPath.toLowerCase() !==
this.sessionSettings.developer.bundledModulesPath.toLowerCase() ||
settings.integratedConsole.useLegacyReadLine !==
this.sessionSettings.integratedConsole.useLegacyReadLine)) {

(settings.cwd?.toLowerCase() !== this.sessionSettings.cwd?.toLowerCase()
|| settings.powerShellDefaultVersion.toLowerCase() !== this.sessionSettings.powerShellDefaultVersion.toLowerCase()
|| settings.developer.editorServicesLogLevel.toLowerCase() !== this.sessionSettings.developer.editorServicesLogLevel.toLowerCase()
|| settings.developer.bundledModulesPath.toLowerCase() !== this.sessionSettings.developer.bundledModulesPath.toLowerCase()
|| settings.integratedConsole.useLegacyReadLine !== this.sessionSettings.integratedConsole.useLegacyReadLine
|| settings.integratedConsole.startInBackground !== this.sessionSettings.integratedConsole.startInBackground)) {
const response: string = await vscode.window.showInformationMessage(
"The PowerShell runtime configuration has changed, would you like to start a new session?",
"Yes", "No");
Expand Down
2 changes: 2 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export interface IStartAsLoginShellSettings {

export interface IIntegratedConsoleSettings {
showOnStartup?: boolean;
startInBackground?: boolean;
focusConsoleOnExecute?: boolean;
useLegacyReadLine?: boolean;
forceClearScrollbackBuffer?: boolean;
Expand Down Expand Up @@ -196,6 +197,7 @@ export function load(): ISettings {

const defaultIntegratedConsoleSettings: IIntegratedConsoleSettings = {
showOnStartup: true,
startInBackground: false,
focusConsoleOnExecute: true,
useLegacyReadLine: false,
forceClearScrollbackBuffer: false,
Expand Down