File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -217,7 +217,8 @@ let hasPrompted = false;
217217export let chosenWorkspace : vscode . WorkspaceFolder | undefined = undefined ;
218218
219219export 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 ) ) {
Original file line number Diff line number Diff 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+
1428export function getPipePath ( pipeName : string ) : string {
1529 if ( os . platform ( ) === "win32" ) {
1630 return "\\\\.\\pipe\\" + pipeName ;
You can’t perform that action at this time.
0 commit comments