mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-27 16:07:46 +00:00
Don't override users' settings
This commit is contained in:
parent
8355233a19
commit
ec45211823
@ -4,7 +4,7 @@ import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import { expectNotUndefined, log, normalizeDriveLetter, unwrapUndefinable } from "./util";
|
||||
import type { Env } from "./util";
|
||||
import { cloneDeep, get, merge, pickBy } from "lodash";
|
||||
import { cloneDeep, get, pickBy, set } from "lodash";
|
||||
|
||||
export type RunnableEnvCfgItem = {
|
||||
mask?: string;
|
||||
@ -220,7 +220,19 @@ export class Config {
|
||||
|
||||
// Returns the final configuration to use, with extension configuration overrides merged in.
|
||||
public get cfg(): ConfigurationTree {
|
||||
return merge(cloneDeep(this.rawCfg), ...Object.values(this.extensionConfigurations));
|
||||
const finalConfig = cloneDeep<ConfigurationTree>(this.rawCfg);
|
||||
for (const [extensionId, items] of Object.entries(this.extensionConfigurations)) {
|
||||
for (const [k, v] of Object.entries(items)) {
|
||||
const i = this.rawCfg.inspect(k);
|
||||
if (i?.workspaceValue !== undefined || i?.workspaceFolderValue !== undefined || i?.globalValue !== undefined) {
|
||||
log.trace(`Ignoring configuration override for ${k} from extension ${extensionId}`);
|
||||
continue;
|
||||
}
|
||||
log.trace(`Extension ${extensionId} overrides configuration ${k} to `, v);
|
||||
set(finalConfig, k, v);
|
||||
}
|
||||
}
|
||||
return finalConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -15,9 +15,9 @@ export interface RustAnalyzerExtensionApi {
|
||||
readonly client?: lc.LanguageClient;
|
||||
|
||||
// Allows adding a configuration override from another extension.
|
||||
// `configuration` is a `rust-analyzer` subtree of the vscode configuration
|
||||
// that gets merged with the workspace/user configuration. `extensionId` is
|
||||
// used to only merge configuration override from present extensions.
|
||||
// `extensionId` is used to only merge configuration override from present
|
||||
// extensions. `configuration` is map of rust-analyzer-specific setting
|
||||
// overrides, e.g., `{"cargo.cfgs": ["foo", "bar"]}`.
|
||||
addConfiguration(extensionId: string, configuration: Record<string, unknown>): Promise<void>;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user