Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d32d1bb

Browse files
Also strip quote pairs from cwd setting
1 parent 9d7b0ef commit d32d1bb

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

‎src/platform.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,11 @@ export class PowerShellExeFinder {
232232
private *enumerateAdditionalPowerShellInstallations(): Iterable<IPossiblePowerShellExe> {
233233
for (const versionName in this.additionalPowerShellExes) {
234234
if (Object.prototype.hasOwnProperty.call(this.additionalPowerShellExes, versionName)) {
235-
let exePath = this.additionalPowerShellExes[versionName];
235+
const exePath = utils.stripQuotePair(this.additionalPowerShellExes[versionName]);
236236
if (!exePath) {
237237
continue;
238238
}
239239

240-
// Remove surrounding quotes from path (without regex)
241-
if (exePath.startsWith("'") && exePath.endsWith("'")
242-
|| exePath.startsWith("\"") && exePath.endsWith("\"")) {
243-
exePath = exePath.slice(1, -1);
244-
}
245-
246240
// Always search for what the user gave us first
247241
yield new PossiblePowerShellExe(exePath, versionName);
248242

‎src/settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ let hasPrompted = false;
217217
export let chosenWorkspace: vscode.WorkspaceFolder | undefined = undefined;
218218

219219
export async function validateCwdSetting(logger: ILogger): Promise<string> {
220-
let cwd: string | undefined = vscode.workspace.getConfiguration(utils.PowerShellLanguageId).get<string>("cwd");
220+
let cwd: string | undefined = utils.stripQuotePair(
221+
vscode.workspace.getConfiguration(utils.PowerShellLanguageId).get<string>("cwd"));
221222

222223
// Only use the cwd setting if it exists.
223224
if (cwd !== undefined && await utils.checkIfDirectoryExists(cwd)) {

‎src/utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ export function escapeSingleQuotes(p: string): string {
1111
return p.replace(new RegExp("'", "g"), "''");
1212
}
1313

14+
export function stripQuotePair(p: string | undefined): string | undefined {
15+
if (p === undefined) {
16+
return p;
17+
}
18+
19+
// Remove matching surrounding quotes from p (without regex)
20+
if (p.startsWith("'") && p.endsWith("'")
21+
|| p.startsWith("\"") && p.endsWith("\"")) {
22+
return p.slice(1, -1);
23+
}
24+
25+
return p;
26+
}
27+
1428
export function getPipePath(pipeName: string): string {
1529
if (os.platform() === "win32") {
1630
return "\\\\.\\pipe\\" + pipeName;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /