From 34cde2cebc67b0b99b5c738f948497691d0ed5e3 Mon Sep 17 00:00:00 2001 From: hkalbasi Date: Fri, 29 Mar 2024 18:08:16 +0330 Subject: [PATCH] Prompt the user to reload the window when enabling test explorer --- editors/code/src/config.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 92a816bfbcb7..e676bc0826c7 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -19,7 +19,7 @@ export class Config { configureLang: vscode.Disposable | undefined; readonly rootSection = "rust-analyzer"; - private readonly requiresReloadOpts = [ + private readonly requiresServerReloadOpts = [ "cargo", "procMacro", "serverPath", @@ -27,6 +27,10 @@ export class Config { "files", ].map((opt) => `${this.rootSection}.${opt}`); + private readonly requiresWindowReloadOpts = ["testExplorer"].map( + (opt) => `${this.rootSection}.${opt}`, + ); + readonly package: { version: string; releaseTag: string | null; @@ -66,18 +70,31 @@ export class Config { this.configureLanguage(); - const requiresReloadOpt = this.requiresReloadOpts.find((opt) => + const requiresWindowReloadOpt = this.requiresWindowReloadOpts.find((opt) => + event.affectsConfiguration(opt), + ); + + if (requiresWindowReloadOpt) { + const message = `Changing "${requiresWindowReloadOpt}" requires a window reload`; + const userResponse = await vscode.window.showInformationMessage(message, "Reload now"); + + if (userResponse) { + await vscode.commands.executeCommand("workbench.action.reloadWindow"); + } + } + + const requiresServerReloadOpt = this.requiresServerReloadOpts.find((opt) => event.affectsConfiguration(opt), ); - if (!requiresReloadOpt) return; + if (!requiresServerReloadOpt) return; if (this.restartServerOnConfigChange) { await vscode.commands.executeCommand("rust-analyzer.restartServer"); return; } - const message = `Changing "${requiresReloadOpt}" requires a server restart`; + const message = `Changing "${requiresServerReloadOpt}" requires a server restart`; const userResponse = await vscode.window.showInformationMessage(message, "Restart now"); if (userResponse) {