Skip to content

Commit 55bf51d

Browse files
committed
Auto merge of rust-lang#13087 - Veykril:config-update, r=Veykril
Remove auto-config patching from the VSCode client This was introduced 4 months ago when we drastically changed the config keys. I'd like to remove this given I always felt uneasy doing edits to a users config from within r-a, and by now most if not all users should've swapped to a new enough version of r-a that should've updated their configs. The extension will continue to work fine even with the outdated keys afterwards since we still do patching server side as well, and that one we'll have to support for quite some more time (if not until a proper 1.0 release where I assume we can allow ourselves some more user facing breakage) (There also might've been a small bug in here that prevented users with certain outdated keys to prevent them from enabling certain keys for some reason)
2 parents 5c52e05 + b19f78b commit 55bf51d

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
@@ -173,100 +173,6 @@ export class Config {
173173
}
174174
}
175175

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

0 commit comments

Comments
 (0)