Skip to content

Commit cc8140a

Browse files
committed
Auto merge of rust-lang#12371 - jhgg:fix/extra-env-non-string-value-handling, r=lnicola
vscode: fix extraEnv handling numeric values fixes rust-lang#12363 by bringing the types more inline with the reality, and making `Env` not a lie.
2 parents 81805d4 + b8ee992 commit cc8140a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

editors/code/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@
308308
"null",
309309
"object"
310310
],
311+
"additionalProperties": {
312+
"type": [
313+
"string",
314+
"number"
315+
]
316+
},
311317
"default": null,
312318
"markdownDescription": "Extra environment variables that will be passed to the rust-analyzer executable. Useful for passing e.g. `RA_LOG` for debugging."
313319
},

editors/code/src/config.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ export class Config {
100100
get serverPath() {
101101
return this.get<null | string>("server.path") ?? this.get<null | string>("serverPath");
102102
}
103-
get serverExtraEnv() {
104-
return this.get<Env | null>("server.extraEnv") ?? {};
103+
get serverExtraEnv(): Env {
104+
const extraEnv =
105+
this.get<{ [key: string]: string | number } | null>("server.extraEnv") ?? {};
106+
return Object.fromEntries(
107+
Object.entries(extraEnv).map(([k, v]) => [k, typeof v !== "string" ? v.toString() : v])
108+
);
105109
}
106110
get traceExtension() {
107111
return this.get<boolean>("trace.extension");

0 commit comments

Comments
 (0)