Skip to content

Commit b19f78b

Browse files
committed
Remove auto-config patching from the VSCode client
1 parent dea1639 commit b19f78b

File tree

2 files changed

+0
-100
lines changed

2 files changed

+0
-100
lines changed

editors/code/src/client.ts

-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as Is from "vscode-languageclient/lib/common/utils/is";
55
import { assert } from "./util";
66
import { WorkspaceEdit } from "vscode";
77
import { Workspace } from "./ctx";
8-
import { updateConfig } from "./config";
98
import { substituteVariablesInEnv } from "./config";
109
import { outputChannel, traceOutputChannel } from "./main";
1110
import { randomUUID } from "crypto";
@@ -86,11 +85,6 @@ export async function createClient(
8685

8786
let initializationOptions = vscode.workspace.getConfiguration("rust-analyzer");
8887

89-
// Update outdated user configs
90-
await updateConfig(initializationOptions).catch((err) => {
91-
void vscode.window.showErrorMessage(`Failed updating old config keys: ${err.message}`);
92-
});
93-
9488
if (workspace.kind === "Detached Files") {
9589
initializationOptions = {
9690
detachedFiles: workspace.files.map((file) => file.uri.fsPath),

editors/code/src/config.ts

-94
Original file line numberDiff line numberDiff line change
@@ -175,100 +175,6 @@ export class Config {
175175
}
176176
}
177177

178-
export async function updateConfig(config: vscode.WorkspaceConfiguration) {
179-
const renames = [
180-
["assist.allowMergingIntoGlobImports", "imports.merge.glob"],
181-
["assist.exprFillDefault", "assist.expressionFillDefault"],
182-
["assist.importEnforceGranularity", "imports.granularity.enforce"],
183-
["assist.importGranularity", "imports.granularity.group"],
184-
["assist.importMergeBehavior", "imports.granularity.group"],
185-
["assist.importMergeBehaviour", "imports.granularity.group"],
186-
["assist.importGroup", "imports.group.enable"],
187-
["assist.importPrefix", "imports.prefix"],
188-
["primeCaches.enable", "cachePriming.enable"],
189-
["cache.warmup", "cachePriming.enable"],
190-
["cargo.loadOutDirsFromCheck", "cargo.buildScripts.enable"],
191-
["cargo.runBuildScripts", "cargo.buildScripts.enable"],
192-
["cargo.runBuildScriptsCommand", "cargo.buildScripts.overrideCommand"],
193-
["cargo.useRustcWrapperForBuildScripts", "cargo.buildScripts.useRustcWrapper"],
194-
["completion.snippets", "completion.snippets.custom"],
195-
["diagnostics.enableExperimental", "diagnostics.experimental.enable"],
196-
["experimental.procAttrMacros", "procMacro.attributes.enable"],
197-
["highlighting.strings", "semanticHighlighting.strings.enable"],
198-
["highlightRelated.breakPoints", "highlightRelated.breakPoints.enable"],
199-
["highlightRelated.exitPoints", "highlightRelated.exitPoints.enable"],
200-
["highlightRelated.yieldPoints", "highlightRelated.yieldPoints.enable"],
201-
["highlightRelated.references", "highlightRelated.references.enable"],
202-
["hover.documentation", "hover.documentation.enable"],
203-
["hover.linksInHover", "hover.links.enable"],
204-
["hoverActions.linksInHover", "hover.links.enable"],
205-
["hoverActions.debug", "hover.actions.debug.enable"],
206-
["hoverActions.enable", "hover.actions.enable.enable"],
207-
["hoverActions.gotoTypeDef", "hover.actions.gotoTypeDef.enable"],
208-
["hoverActions.implementations", "hover.actions.implementations.enable"],
209-
["hoverActions.references", "hover.actions.references.enable"],
210-
["hoverActions.run", "hover.actions.run.enable"],
211-
["inlayHints.chainingHints", "inlayHints.chainingHints.enable"],
212-
["inlayHints.closureReturnTypeHints", "inlayHints.closureReturnTypeHints.enable"],
213-
["inlayHints.hideNamedConstructorHints", "inlayHints.typeHints.hideNamedConstructor"],
214-
["inlayHints.parameterHints", "inlayHints.parameterHints.enable"],
215-
["inlayHints.reborrowHints", "inlayHints.reborrowHints.enable"],
216-
["inlayHints.typeHints", "inlayHints.typeHints.enable"],
217-
["lruCapacity", "lru.capacity"],
218-
["runnables.cargoExtraArgs", "runnables.extraArgs"],
219-
["runnables.overrideCargo", "runnables.command"],
220-
["rustcSource", "rustc.source"],
221-
["rustfmt.enableRangeFormatting", "rustfmt.rangeFormatting.enable"],
222-
];
223-
224-
for (const [oldKey, newKey] of renames) {
225-
const inspect = config.inspect(oldKey);
226-
if (inspect !== undefined) {
227-
const valMatrix = [
228-
{
229-
val: inspect.globalValue,
230-
langVal: inspect.globalLanguageValue,
231-
target: vscode.ConfigurationTarget.Global,
232-
},
233-
{
234-
val: inspect.workspaceFolderValue,
235-
langVal: inspect.workspaceFolderLanguageValue,
236-
target: vscode.ConfigurationTarget.WorkspaceFolder,
237-
},
238-
{
239-
val: inspect.workspaceValue,
240-
langVal: inspect.workspaceLanguageValue,
241-
target: vscode.ConfigurationTarget.Workspace,
242-
},
243-
];
244-
for (const { val, langVal, target } of valMatrix) {
245-
const patch = (val: unknown) => {
246-
// some of the updates we do only append "enable" or "custom"
247-
// that means on the next run we would find these again, but as objects with
248-
// these properties causing us to destroy the config
249-
// so filter those already updated ones out
250-
return (
251-
val !== undefined &&
252-
!(
253-
typeof val === "object" &&
254-
val !== null &&
255-
(oldKey === "completion.snippets" || !val.hasOwnProperty("custom"))
256-
)
257-
);
258-
};
259-
if (patch(val)) {
260-
await config.update(newKey, val, target, false);
261-
await config.update(oldKey, undefined, target, false);
262-
}
263-
if (patch(langVal)) {
264-
await config.update(newKey, langVal, target, true);
265-
await config.update(oldKey, undefined, target, true);
266-
}
267-
}
268-
}
269-
}
270-
}
271-
272178
export function substituteVariablesInEnv(env: Env): Env {
273179
const missingDeps = new Set<string>();
274180
// vscode uses `env:ENV_NAME` for env vars resolution, and it's easier

0 commit comments

Comments
 (0)