Skip to content

Commit

Permalink
Auto merge of #16975 - HKalbasi:test-explorer, r=HKalbasi
Browse files Browse the repository at this point in the history
Prompt the user to reload the window when enabling test explorer
  • Loading branch information
bors committed Mar 29, 2024
2 parents 9d84142 + 34cde2c commit f5a9250
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions editors/code/src/config.ts
Expand Up @@ -19,14 +19,18 @@ export class Config {
configureLang: vscode.Disposable | undefined;

readonly rootSection = "rust-analyzer";
private readonly requiresReloadOpts = [
private readonly requiresServerReloadOpts = [
"cargo",
"procMacro",
"serverPath",
"server",
"files",
].map((opt) => `${this.rootSection}.${opt}`);

private readonly requiresWindowReloadOpts = ["testExplorer"].map(
(opt) => `${this.rootSection}.${opt}`,
);

readonly package: {
version: string;
releaseTag: string | null;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f5a9250

Please sign in to comment.