File tree 3 files changed +17
-8
lines changed
3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -232,17 +232,11 @@ export class PowerShellExeFinder {
232
232
private * enumerateAdditionalPowerShellInstallations ( ) : Iterable < IPossiblePowerShellExe > {
233
233
for ( const versionName in this . additionalPowerShellExes ) {
234
234
if ( Object . prototype . hasOwnProperty . call ( this . additionalPowerShellExes , versionName ) ) {
235
- let exePath = this . additionalPowerShellExes [ versionName ] ;
235
+ const exePath = utils . stripQuotePair ( this . additionalPowerShellExes [ versionName ] ) ;
236
236
if ( ! exePath ) {
237
237
continue ;
238
238
}
239
239
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
-
246
240
// Always search for what the user gave us first
247
241
yield new PossiblePowerShellExe ( exePath , versionName ) ;
248
242
Original file line number Diff line number Diff line change @@ -217,7 +217,8 @@ let hasPrompted = false;
217
217
export let chosenWorkspace : vscode . WorkspaceFolder | undefined = undefined ;
218
218
219
219
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" ) ) ;
221
222
222
223
// Only use the cwd setting if it exists.
223
224
if ( cwd !== undefined && await utils . checkIfDirectoryExists ( cwd ) ) {
Original file line number Diff line number Diff line change @@ -11,6 +11,20 @@ export function escapeSingleQuotes(p: string): string {
11
11
return p . replace ( new RegExp ( "'" , "g" ) , "''" ) ;
12
12
}
13
13
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
+
14
28
export function getPipePath ( pipeName : string ) : string {
15
29
if ( os . platform ( ) === "win32" ) {
16
30
return "\\\\.\\pipe\\" + pipeName ;
You can’t perform that action at this time.
0 commit comments