mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
fix: Ask the user to reload the vscode window when changing server settings
This commit is contained in:
parent
7db73875ac
commit
002447d6cb
@ -16,14 +16,17 @@ export class Config {
|
|||||||
readonly extensionId = "rust-lang.rust-analyzer";
|
readonly extensionId = "rust-lang.rust-analyzer";
|
||||||
|
|
||||||
readonly rootSection = "rust-analyzer";
|
readonly rootSection = "rust-analyzer";
|
||||||
|
private readonly requiresWorkspaceReloadOpts = ["serverPath", "server"].map(
|
||||||
|
(opt) => `${this.rootSection}.${opt}`
|
||||||
|
);
|
||||||
private readonly requiresReloadOpts = [
|
private readonly requiresReloadOpts = [
|
||||||
"serverPath",
|
|
||||||
"server",
|
|
||||||
"cargo",
|
"cargo",
|
||||||
"procMacro",
|
"procMacro",
|
||||||
"files",
|
"files",
|
||||||
"lens", // works as lens.*
|
"lens", // works as lens.*
|
||||||
].map((opt) => `${this.rootSection}.${opt}`);
|
]
|
||||||
|
.map((opt) => `${this.rootSection}.${opt}`)
|
||||||
|
.concat(this.requiresWorkspaceReloadOpts);
|
||||||
|
|
||||||
readonly package: {
|
readonly package: {
|
||||||
version: string;
|
version: string;
|
||||||
@ -60,16 +63,26 @@ export class Config {
|
|||||||
|
|
||||||
if (!requiresReloadOpt) return;
|
if (!requiresReloadOpt) return;
|
||||||
|
|
||||||
if (this.restartServerOnConfigChange) {
|
const requiresWorkspaceReloadOpt = this.requiresWorkspaceReloadOpts.find((opt) =>
|
||||||
await vscode.commands.executeCommand("rust-analyzer.reload");
|
event.affectsConfiguration(opt)
|
||||||
} else {
|
);
|
||||||
const userResponse = await vscode.window.showInformationMessage(
|
|
||||||
`Changing "${requiresReloadOpt}" requires a reload`,
|
|
||||||
"Reload now"
|
|
||||||
);
|
|
||||||
|
|
||||||
|
if (!requiresWorkspaceReloadOpt && this.restartServerOnConfigChange) {
|
||||||
|
await vscode.commands.executeCommand("rust-analyzer.reload");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = requiresWorkspaceReloadOpt
|
||||||
|
? `Changing "${requiresWorkspaceReloadOpt}" requires a window reload`
|
||||||
|
: `Changing "${requiresReloadOpt}" requires a reload`;
|
||||||
|
const userResponse = await vscode.window.showInformationMessage(message, "Reload now");
|
||||||
|
|
||||||
|
if (userResponse === "Reload now") {
|
||||||
|
const command = requiresWorkspaceReloadOpt
|
||||||
|
? "workbench.action.reloadWindow"
|
||||||
|
: "rust-analyzer.reload";
|
||||||
if (userResponse === "Reload now") {
|
if (userResponse === "Reload now") {
|
||||||
await vscode.commands.executeCommand("rust-analyzer.reload");
|
await vscode.commands.executeCommand(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user