mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
Auto merge of #13510 - Veykril:status-click, r=Veykril
feat: Clicking the status bar item stops and starts the server
This commit is contained in:
commit
e69014a81e
2 changed files with 11 additions and 6 deletions
|
@ -204,13 +204,13 @@ export class Ctx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setServerStatus(status: ServerStatusParams) {
|
setServerStatus(status: ServerStatusParams | { health: "stopped" }) {
|
||||||
let icon = "";
|
let icon = "";
|
||||||
const statusBar = this.statusBar;
|
const statusBar = this.statusBar;
|
||||||
switch (status.health) {
|
switch (status.health) {
|
||||||
case "ok":
|
case "ok":
|
||||||
statusBar.tooltip = status.message ?? "Ready";
|
statusBar.tooltip = (status.message ?? "Ready") + "Click to stop.";
|
||||||
statusBar.command = undefined;
|
statusBar.command = "rust-analyzer.stopServer";
|
||||||
statusBar.color = undefined;
|
statusBar.color = undefined;
|
||||||
statusBar.backgroundColor = undefined;
|
statusBar.backgroundColor = undefined;
|
||||||
break;
|
break;
|
||||||
|
@ -234,6 +234,13 @@ export class Ctx {
|
||||||
statusBar.backgroundColor = new vscode.ThemeColor("statusBarItem.errorBackground");
|
statusBar.backgroundColor = new vscode.ThemeColor("statusBarItem.errorBackground");
|
||||||
icon = "$(error) ";
|
icon = "$(error) ";
|
||||||
break;
|
break;
|
||||||
|
case "stopped":
|
||||||
|
statusBar.tooltip = "Server is stopped. Click to start.";
|
||||||
|
statusBar.command = "rust-analyzer.startServer";
|
||||||
|
statusBar.color = undefined;
|
||||||
|
statusBar.backgroundColor = undefined;
|
||||||
|
statusBar.text = `$(stop-circle) rust-analyzer`;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!status.quiescent) icon = "$(sync~spin) ";
|
if (!status.quiescent) icon = "$(sync~spin) ";
|
||||||
statusBar.text = `${icon}rust-analyzer`;
|
statusBar.text = `${icon}rust-analyzer`;
|
||||||
|
|
|
@ -120,9 +120,7 @@ function createCommands(): Record<string, CommandFactory> {
|
||||||
// FIXME: We should re-use the client, that is ctx.deactivate() if none of the configs have changed
|
// FIXME: We should re-use the client, that is ctx.deactivate() if none of the configs have changed
|
||||||
await ctx.stop();
|
await ctx.stop();
|
||||||
ctx.setServerStatus({
|
ctx.setServerStatus({
|
||||||
health: "ok",
|
health: "stopped",
|
||||||
quiescent: true,
|
|
||||||
message: "server is not running",
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue