Skip to content

Commit

Permalink
Auto merge of rust-lang#12371 - jhgg:fix/extra-env-non-string-value-h…
Browse files Browse the repository at this point in the history
…andling, 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.
  • Loading branch information
bors committed May 24, 2022
2 parents 81805d4 + b8ee992 commit cc8140a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
},
Expand Down
8 changes: 6 additions & 2 deletions editors/code/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit cc8140a

Please sign in to comment.