Skip to content

Commit

Permalink
feat: support paths which contain whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmu committed Aug 2, 2024
1 parent c48f30d commit c001fe2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 14 additions & 1 deletion src/lib/ripgrep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function getRgCommand(value: string, extraFlags?: string[]) {
...config.rgOptions,
...cx.rgMenuActionsSelected,
...rootPaths,
...config.addSrcPaths,
...config.addSrcPaths.map(ensureQuotedPath),
...(extraFlags || []),
...excludes,
];
Expand Down Expand Up @@ -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}"`;
}

0 comments on commit c001fe2

Please sign in to comment.