Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore VsCode 1.91 behavior of allowing scripts as executable #730

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ recommend to run `npm run format` before sending a patch.

To create a new release, create a commit that:

- increases the version number in `package.json`
- increases the version number in `package.json` and `package-lock.json`
- updates `CHANGELOG.md` to cover changes since the last release

Our CI will recognize the commit and publish new versions to the VSCode
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"description": "In restricted mode clangd.path and clangd.arguments are not respected.",
"restrictedConfigurations": [
"clangd.path",
"clangd.useScriptAsExecutable",
"clangd.arguments"
]
}
Expand All @@ -103,6 +104,12 @@
"scope": "machine-overridable",
"description": "The path to clangd executable, e.g.: /usr/bin/clangd."
},
"clangd.useScriptAsExecutable": {
"type": "boolean",
"default": "false",
"scope": "machine-overridable",
"description": "Allows the path to be a script e.g.: clangd.sh."
},
"clangd.arguments": {
"type": "array",
"default": [],
Expand Down
14 changes: 12 additions & 2 deletions src/clangd-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,23 @@ export class ClangdContext implements vscode.Disposable {
if (!clangdPath)
return null;

const useScriptAsExecutable =
await config.get<boolean>('useScriptAsExecutable');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified this a bit in #731 (config.get isn't actually async and doesn't need to be awaited), would you mind rebasing on top of that and querying the config value directly in the constructor?

const clangdArguments = await config.get<string[]>('arguments');

return new ClangdContext(clangdPath, clangdArguments, outputChannel);
return new ClangdContext(clangdPath, clangdArguments, outputChannel,
useScriptAsExecutable);
}

private constructor(clangdPath: string, clangdArguments: string[],
outputChannel: vscode.OutputChannel) {
outputChannel: vscode.OutputChannel,
useScriptAsExecutable: boolean) {
if (useScriptAsExecutable) {
let quote = (str: string) => { return `"${str}"`; };
clangdPath = quote(clangdPath)
for (var i = 0; i < clangdArguments.length; i++)
clangdArguments[i] = quote(clangdArguments[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent statement inside loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree, will look at it

}
const clangd: vscodelc.Executable = {
command: clangdPath,
args: clangdArguments,
Expand Down
Loading