Skip to content

Commit e44c3c4

Browse files
Don't override users' settings
1 parent 6de1792 commit e44c3c4

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/tools/rust-analyzer/editors/code/src/config.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from "path";
44
import * as vscode from "vscode";
55
import { expectNotUndefined, log, normalizeDriveLetter, unwrapUndefinable } from "./util";
66
import type { Env } from "./util";
7-
import { cloneDeep, get, merge, pickBy } from "lodash";
7+
import { cloneDeep, get, pickBy, set } from "lodash";
88

99
export type RunnableEnvCfgItem = {
1010
mask?: string;
@@ -220,7 +220,19 @@ export class Config {
220220

221221
// Returns the final configuration to use, with extension configuration overrides merged in.
222222
public get cfg(): ConfigurationTree {
223-
return merge(cloneDeep(this.rawCfg), ...Object.values(this.extensionConfigurations));
223+
const finalConfig = cloneDeep<ConfigurationTree>(this.rawCfg);
224+
for (const [extensionId, items] of Object.entries(this.extensionConfigurations)) {
225+
for (const [k, v] of Object.entries(items)) {
226+
const i = this.rawCfg.inspect(k);
227+
if (i?.workspaceValue !== undefined || i?.workspaceFolderValue !== undefined || i?.globalValue !== undefined) {
228+
log.trace(`Ignoring configuration override for ${k} from extension ${extensionId}`);
229+
continue;
230+
}
231+
log.trace(`Extension ${extensionId} overrides configuration ${k} to `, v);
232+
set(finalConfig, k, v);
233+
}
234+
}
235+
return finalConfig;
224236
}
225237

226238
/**

src/tools/rust-analyzer/editors/code/src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export interface RustAnalyzerExtensionApi {
1515
readonly client?: lc.LanguageClient;
1616

1717
// Allows adding a configuration override from another extension.
18-
// `configuration` is a `rust-analyzer` subtree of the vscode configuration
19-
// that gets merged with the workspace/user configuration. `extensionId` is
20-
// used to only merge configuration override from present extensions.
18+
// `extensionId` is used to only merge configuration override from present
19+
// extensions. `configuration` is map of rust-analyzer-specific setting
20+
// overrides, e.g., `{"cargo.cfgs": ["foo", "bar"]}`.
2121
addConfiguration(extensionId: string, configuration: Record<string, unknown>): Promise<void>;
2222
}
2323

0 commit comments

Comments
 (0)