From a2236c87797bc1c88e384f3d4b5be2d58f387535 Mon Sep 17 00:00:00 2001 From: jwfx Date: Sun, 5 Jul 2020 15:12:33 +0200 Subject: [PATCH 1/3] Add setting to change the cwd of the Powershell Integrated Console --- package.json | 5 +++++ src/process.ts | 1 + src/settings.ts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/package.json b/package.json index 6be8cea30c..93c275638b 100644 --- a/package.json +++ b/package.json @@ -781,6 +781,11 @@ "default": false, "description": "Do not show the Powershell Integrated Console banner on launch" }, + "powershell.integratedConsole.cwd": { + "type": "string", + "default": null, + "description": "An explicit start path where the Powershell Integrated Console will be launched. Predefined variables can be used (i.e. ${fileDirname} to use the current opened file's directory" + }, "powershell.debugging.createTemporaryIntegratedConsole": { "type": "boolean", "default": false, diff --git a/src/process.ts b/src/process.ts index 80b849ef48..7d42d6cb95 100644 --- a/src/process.ts +++ b/src/process.ts @@ -112,6 +112,7 @@ export class PowerShellProcess { shellPath: this.exePath, shellArgs: powerShellArgs, hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup, + cwd: this.sessionSettings.integratedConsole.cwd }); const pwshName = path.basename(this.exePath); diff --git a/src/settings.ts b/src/settings.ts index defbdd9e7a..39045c6e80 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -114,6 +114,7 @@ export interface IIntegratedConsoleSettings { useLegacyReadLine?: boolean; forceClearScrollbackBuffer?: boolean; suppressStartupBanner?: boolean; + cwd?: string } export interface ISideBarSettings { @@ -192,6 +193,7 @@ export function load(): ISettings { focusConsoleOnExecute: true, useLegacyReadLine: false, forceClearScrollbackBuffer: false, + cwd: null }; const defaultSideBarSettings: ISideBarSettings = { From cd226b0fceb85c7e3f971f341091c145e1bcae1b Mon Sep 17 00:00:00 2001 From: jwfx Date: Mon, 6 Jul 2020 21:13:22 +0200 Subject: [PATCH 2/3] Changet setting from powershell.integratedConsole.cwd to powershell.cwd --- package.json | 10 +++++----- src/process.ts | 5 ++++- src/settings.ts | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 93c275638b..01cbe91077 100644 --- a/package.json +++ b/package.json @@ -640,6 +640,11 @@ "default": "BlockComment", "description": "Controls the comment-based help completion behavior triggered by typing '##'. Set the generated help style with 'BlockComment' or 'LineComment'. Disable the feature with 'Disabled'." }, + "powershell.cwd": { + "type": "string", + "default": null, + "description": "An explicit start path where the Powershell Integrated Console will be launched. Open workspace folders will take precedence over this setting. Predefined variables can be used (i.e. ${fileDirname} to use the current opened file's directory)." + }, "powershell.scriptAnalysis.enable": { "type": "boolean", "default": true, @@ -781,11 +786,6 @@ "default": false, "description": "Do not show the Powershell Integrated Console banner on launch" }, - "powershell.integratedConsole.cwd": { - "type": "string", - "default": null, - "description": "An explicit start path where the Powershell Integrated Console will be launched. Predefined variables can be used (i.e. ${fileDirname} to use the current opened file's directory" - }, "powershell.debugging.createTemporaryIntegratedConsole": { "type": "boolean", "default": false, diff --git a/src/process.ts b/src/process.ts index 7d42d6cb95..0245cdba80 100644 --- a/src/process.ts +++ b/src/process.ts @@ -105,6 +105,9 @@ export class PowerShellProcess { // Make sure no old session file exists utils.deleteSessionFile(this.sessionFilePath); + // Open workspace folders take precedence over cwd setting + const cwd = vscode.workspace.workspaceFolders === undefined ? this.sessionSettings.cwd : null; + // Launch PowerShell in the integrated terminal this.consoleTerminal = vscode.window.createTerminal({ @@ -112,7 +115,7 @@ export class PowerShellProcess { shellPath: this.exePath, shellArgs: powerShellArgs, hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup, - cwd: this.sessionSettings.integratedConsole.cwd + cwd }); const pwshName = path.basename(this.exePath); diff --git a/src/settings.ts b/src/settings.ts index 39045c6e80..9cd5883084 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -101,6 +101,7 @@ export interface ISettings { sideBar?: ISideBarSettings; pester?: IPesterSettings; buttons?: IButtonSettings; + cwd?: string; } export interface IStartAsLoginShellSettings { @@ -114,7 +115,6 @@ export interface IIntegratedConsoleSettings { useLegacyReadLine?: boolean; forceClearScrollbackBuffer?: boolean; suppressStartupBanner?: boolean; - cwd?: string } export interface ISideBarSettings { @@ -193,7 +193,6 @@ export function load(): ISettings { focusConsoleOnExecute: true, useLegacyReadLine: false, forceClearScrollbackBuffer: false, - cwd: null }; const defaultSideBarSettings: ISideBarSettings = { @@ -259,6 +258,8 @@ export function load(): ISettings { // is the reason terminals on macOS typically run login shells by default which set up // the environment. See http://unix.stackexchange.com/a/119675/115410" configuration.get("startAsLoginShell", defaultStartAsLoginShellSettings), + cwd: + configuration.get("cwd", null), }; } From 0e63081b142795fe8c12ce623f2bf1cd11e5f434 Mon Sep 17 00:00:00 2001 From: jwfx Date: Tue, 7 Jul 2020 18:09:59 +0200 Subject: [PATCH 3/3] pwsh location for opened folders must be solved in PSES --- package.json | 2 +- src/process.ts | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 01cbe91077..17be43133f 100644 --- a/package.json +++ b/package.json @@ -643,7 +643,7 @@ "powershell.cwd": { "type": "string", "default": null, - "description": "An explicit start path where the Powershell Integrated Console will be launched. Open workspace folders will take precedence over this setting. Predefined variables can be used (i.e. ${fileDirname} to use the current opened file's directory)." + "description": "An explicit start path where the Powershell Integrated Console will be launched. Both the PowerShell process and the shell's location will be set to this directory. Predefined variables can be used (i.e. ${fileDirname} to use the current opened file's directory)." }, "powershell.scriptAnalysis.enable": { "type": "boolean", diff --git a/src/process.ts b/src/process.ts index 0245cdba80..7f9f08b185 100644 --- a/src/process.ts +++ b/src/process.ts @@ -105,9 +105,6 @@ export class PowerShellProcess { // Make sure no old session file exists utils.deleteSessionFile(this.sessionFilePath); - // Open workspace folders take precedence over cwd setting - const cwd = vscode.workspace.workspaceFolders === undefined ? this.sessionSettings.cwd : null; - // Launch PowerShell in the integrated terminal this.consoleTerminal = vscode.window.createTerminal({ @@ -115,7 +112,7 @@ export class PowerShellProcess { shellPath: this.exePath, shellArgs: powerShellArgs, hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup, - cwd + cwd: this.sessionSettings.cwd }); const pwshName = path.basename(this.exePath);