Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #12371 - jhgg:fix/extra-env-non-string-value-handling, r=lnicola
vscode: fix extraEnv handling numeric values fixes #12363 by bringing the types more inline with the reality, and making `Env` not a lie.
bors 2022-05-24
parent 81805d4 · parent b8ee992 · commit cc8140a
-rw-r--r--editors/code/package.json6
-rw-r--r--editors/code/src/config.ts8
2 files changed, 12 insertions, 2 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index f46c7ea92d..18fa7f2f4c 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -308,6 +308,12 @@
"null",
"object"
],
+ "additionalProperties": {
+ "type": [
+ "string",
+ "number"
+ ]
+ },
"default": null,
"markdownDescription": "Extra environment variables that will be passed to the rust-analyzer executable. Useful for passing e.g. `RA_LOG` for debugging."
},
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 592ebe0ce3..d07e47c8de 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -100,8 +100,12 @@ export class Config {
get serverPath() {
return this.get<null | string>("server.path") ?? this.get<null | string>("serverPath");
}
- get serverExtraEnv() {
- return this.get<Env | null>("server.extraEnv") ?? {};
+ get serverExtraEnv(): Env {
+ const extraEnv =
+ this.get<{ [key: string]: string | number } | null>("server.extraEnv") ?? {};
+ return Object.fromEntries(
+ Object.entries(extraEnv).map(([k, v]) => [k, typeof v !== "string" ? v.toString() : v])
+ );
}
get traceExtension() {
return this.get<boolean>("trace.extension");