Auto merge of #16975 - HKalbasi:test-explorer, r=HKalbasi
Prompt the user to reload the window when enabling test explorer
This commit is contained in:
commit
f5a9250147
@ -19,7 +19,7 @@ export class Config {
|
|||||||
configureLang: vscode.Disposable | undefined;
|
configureLang: vscode.Disposable | undefined;
|
||||||
|
|
||||||
readonly rootSection = "rust-analyzer";
|
readonly rootSection = "rust-analyzer";
|
||||||
private readonly requiresReloadOpts = [
|
private readonly requiresServerReloadOpts = [
|
||||||
"cargo",
|
"cargo",
|
||||||
"procMacro",
|
"procMacro",
|
||||||
"serverPath",
|
"serverPath",
|
||||||
@ -27,6 +27,10 @@ export class Config {
|
|||||||
"files",
|
"files",
|
||||||
].map((opt) => `${this.rootSection}.${opt}`);
|
].map((opt) => `${this.rootSection}.${opt}`);
|
||||||
|
|
||||||
|
private readonly requiresWindowReloadOpts = ["testExplorer"].map(
|
||||||
|
(opt) => `${this.rootSection}.${opt}`,
|
||||||
|
);
|
||||||
|
|
||||||
readonly package: {
|
readonly package: {
|
||||||
version: string;
|
version: string;
|
||||||
releaseTag: string | null;
|
releaseTag: string | null;
|
||||||
@ -66,18 +70,31 @@ export class Config {
|
|||||||
|
|
||||||
this.configureLanguage();
|
this.configureLanguage();
|
||||||
|
|
||||||
const requiresReloadOpt = this.requiresReloadOpts.find((opt) =>
|
const requiresWindowReloadOpt = this.requiresWindowReloadOpts.find((opt) =>
|
||||||
event.affectsConfiguration(opt),
|
event.affectsConfiguration(opt),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!requiresReloadOpt) return;
|
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 (!requiresServerReloadOpt) return;
|
||||||
|
|
||||||
if (this.restartServerOnConfigChange) {
|
if (this.restartServerOnConfigChange) {
|
||||||
await vscode.commands.executeCommand("rust-analyzer.restartServer");
|
await vscode.commands.executeCommand("rust-analyzer.restartServer");
|
||||||
return;
|
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");
|
const userResponse = await vscode.window.showInformationMessage(message, "Restart now");
|
||||||
|
|
||||||
if (userResponse) {
|
if (userResponse) {
|
||||||
|
Loading…
Reference in New Issue
Block a user