Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts29
1 files changed, 25 insertions, 4 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 1faa0ad910..da7c74c28b 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -34,6 +34,7 @@ export class Config {
constructor(ctx: vscode.ExtensionContext) {
this.globalStorageUri = ctx.globalStorageUri;
+ this.discoveredWorkspaces = [];
vscode.workspace.onDidChangeConfiguration(
this.onDidChangeConfiguration,
this,
@@ -55,6 +56,8 @@ export class Config {
log.info("Using configuration", Object.fromEntries(cfg));
}
+ public discoveredWorkspaces: JsonProject[];
+
private async onDidChangeConfiguration(event: vscode.ConfigurationChangeEvent) {
this.refreshLogging();
@@ -191,7 +194,7 @@ export class Config {
* So this getter handles this quirk by not requiring the caller to use postfix `!`
*/
private get<T>(path: string): T | undefined {
- return substituteVSCodeVariables(this.cfg.get<T>(path));
+ return prepareVSCodeConfig(this.cfg.get<T>(path));
}
get serverPath() {
@@ -214,6 +217,10 @@ export class Config {
return this.get<boolean>("trace.extension");
}
+ get discoverProjectCommand() {
+ return this.get<string[] | undefined>("discoverProjectCommand");
+ }
+
get cargoRunner() {
return this.get<string | undefined>("cargoRunner");
}
@@ -280,18 +287,32 @@ export class Config {
}
}
-export function substituteVSCodeVariables<T>(resp: T): T {
+// the optional `cb?` parameter is meant to be used to add additional
+// key/value pairs to the VS Code configuration. This needed for, e.g.,
+// including a `rust-project.json` into the `linkedProjects` key as part
+// of the configuration/InitializationParams _without_ causing VS Code
+// configuration to be written out to workspace-level settings. This is
+// undesirable behavior because rust-project.json files can be tens of
+// thousands of lines of JSON, most of which is not meant for humans
+// to interact with.
+export function prepareVSCodeConfig<T>(
+ resp: T,
+ cb?: (key: Extract<keyof T, string>, res: { [key: string]: any }) => void
+): T {
if (Is.string(resp)) {
return substituteVSCodeVariableInString(resp) as T;
} else if (resp && Is.array<any>(resp)) {
return resp.map((val) => {
- return substituteVSCodeVariables(val);
+ return prepareVSCodeConfig(val);
}) as T;
} else if (resp && typeof resp === "object") {
const res: { [key: string]: any } = {};
for (const key in resp) {
const val = resp[key];
- res[key] = substituteVSCodeVariables(val);
+ res[key] = prepareVSCodeConfig(val);
+ if (cb) {
+ cb(key, res);
+ }
}
return res as T;
}