From c001fe2297e1a8a3d4c5ac48b4ae0ce9898e1b57 Mon Sep 17 00:00:00 2001 From: Josh Mu Date: Fri, 2 Aug 2024 17:23:46 +1000 Subject: [PATCH] feat: support paths which contain whitespace --- package-lock.json | 18 +++++++++--------- package.json | 2 +- src/lib/ripgrep.ts | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b72ebc..730be1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "periscope", - "version": "1.6.1", + "version": "1.6.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "periscope", - "version": "1.6.1", + "version": "1.6.10", "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { "@vscode/ripgrep": "^1.15.9" @@ -17,7 +17,7 @@ "@types/glob": "^8.1.0", "@types/mocha": "^10.0.1", "@types/node": "16.x", - "@types/vscode": "^1.76.0", + "@types/vscode": "^1.88.0", "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", "@vscode/test-electron": "^2.2.3", @@ -1057,9 +1057,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.76.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.76.0.tgz", - "integrity": "sha512-CQcY3+Fe5hNewHnOEAVYj4dd1do/QHliXaknAEYSXx2KEHUzFibDZSKptCon+HPgK55xx20pR+PBJjf0MomnBA==", + "version": "1.88.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.88.0.tgz", + "integrity": "sha512-rWY+Bs6j/f1lvr8jqZTyp5arRMfovdxolcqGi+//+cPDOh8SBvzXH90e7BiSXct5HJ9HGW6jATchbRTpTJpEkw==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { @@ -11032,9 +11032,9 @@ "dev": true }, "@types/vscode": { - "version": "1.76.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.76.0.tgz", - "integrity": "sha512-CQcY3+Fe5hNewHnOEAVYj4dd1do/QHliXaknAEYSXx2KEHUzFibDZSKptCon+HPgK55xx20pR+PBJjf0MomnBA==", + "version": "1.88.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.88.0.tgz", + "integrity": "sha512-rWY+Bs6j/f1lvr8jqZTyp5arRMfovdxolcqGi+//+cPDOh8SBvzXH90e7BiSXct5HJ9HGW6jATchbRTpTJpEkw==", "dev": true }, "@typescript-eslint/eslint-plugin": { diff --git a/package.json b/package.json index ff3fb73..94194fa 100644 --- a/package.json +++ b/package.json @@ -212,7 +212,7 @@ "@types/glob": "^8.1.0", "@types/mocha": "^10.0.1", "@types/node": "16.x", - "@types/vscode": "^1.76.0", + "@types/vscode": "^1.88.0", "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", "@vscode/test-electron": "^2.2.3", diff --git a/src/lib/ripgrep.ts b/src/lib/ripgrep.ts index 01915f9..fcb9863 100644 --- a/src/lib/ripgrep.ts +++ b/src/lib/ripgrep.ts @@ -35,7 +35,7 @@ function getRgCommand(value: string, extraFlags?: string[]) { ...config.rgOptions, ...cx.rgMenuActionsSelected, ...rootPaths, - ...config.addSrcPaths, + ...config.addSrcPaths.map(ensureQuotedPath), ...(extraFlags || []), ...excludes, ]; @@ -169,3 +169,16 @@ export function checkAndExtractRgFlagsFromQuery(query: string): { updatedQuery: const updatedQuery = queries.length > 1 ? queries[1] : queries[0]; return { updatedQuery, extraRgFlags }; } + +/** + * Ensure that the src path provided is quoted + * Required when config paths contain whitespace + */ +function ensureQuotedPath(path: string): string { + // support for paths already quoted via config + if (path.startsWith('"') && path.endsWith('"')) { + return path; + } + // else quote the path + return `"${path}"`; +}