diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2023-03-10 10:13:30 +0100 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2023-03-10 10:13:30 +0100 |
| commit | 2cb60343ed3774d4645d7d14dff8a1119d3c6785 (patch) | |
| tree | 650ba91180babc33547000b95e9259100c2be5f7 /editors/code/src/ctx.ts | |
| parent | 0d19ccb3dfb9841ba84367c82a4e75930c189823 (diff) | |
| download | rust-2cb60343ed3774d4645d7d14dff8a1119d3c6785.tar.gz rust-2cb60343ed3774d4645d7d14dff8a1119d3c6785.zip | |
Add fancy buttons to the vscode status message
Diffstat (limited to 'editors/code/src/ctx.ts')
| -rw-r--r-- | editors/code/src/ctx.ts | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index e2a30e0cc45..1708d47cee7 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -282,18 +282,18 @@ export class Ctx { setServerStatus(status: ServerStatusParams | { health: "stopped" }) { let icon = ""; const statusBar = this.statusBar; + statusBar.tooltip = new vscode.MarkdownString("", true); + statusBar.tooltip.isTrusted = true; switch (status.health) { case "ok": - statusBar.tooltip = (status.message ?? "Ready") + "\nClick to stop server."; - statusBar.command = "rust-analyzer.stopServer"; + statusBar.tooltip.appendText(status.message ?? "Ready"); statusBar.color = undefined; statusBar.backgroundColor = undefined; break; case "warning": - statusBar.tooltip = - (status.message ? status.message + "\n" : "") + "Click to reload."; - - statusBar.command = "rust-analyzer.reloadWorkspace"; + if (status.message) { + statusBar.tooltip.appendText(status.message); + } statusBar.color = new vscode.ThemeColor("statusBarItem.warningForeground"); statusBar.backgroundColor = new vscode.ThemeColor( "statusBarItem.warningBackground" @@ -301,22 +301,32 @@ export class Ctx { icon = "$(warning) "; break; case "error": - statusBar.tooltip = - (status.message ? status.message + "\n" : "") + "Click to reload."; - - statusBar.command = "rust-analyzer.reloadWorkspace"; + if (status.message) { + statusBar.tooltip.appendText(status.message); + } statusBar.color = new vscode.ThemeColor("statusBarItem.errorForeground"); statusBar.backgroundColor = new vscode.ThemeColor("statusBarItem.errorBackground"); icon = "$(error) "; break; case "stopped": - statusBar.tooltip = "Server is stopped.\nClick to start."; - statusBar.command = "rust-analyzer.startServer"; + statusBar.tooltip.appendText("Server is stopped"); + statusBar.tooltip.appendMarkdown( + "\n\n[Start server](command:rust-analyzer.startServer)" + ); statusBar.color = undefined; statusBar.backgroundColor = undefined; statusBar.text = `$(stop-circle) rust-analyzer`; return; } + if (statusBar.tooltip.value) { + statusBar.tooltip.appendText("\n\n"); + } + statusBar.tooltip.appendMarkdown("[Stop server](command:rust-analyzer.stopServer)"); + statusBar.tooltip.appendMarkdown( + "\n\n[Reload Workspace](command:rust-analyzer.reloadWorkspace)" + ); + statusBar.tooltip.appendMarkdown("\n\n[Restart server](command:rust-analyzer.startServer)"); + statusBar.tooltip.appendMarkdown("\n\n[Open logs](command:rust-analyzer.openLogs)"); if (!status.quiescent) icon = "$(sync~spin) "; statusBar.text = `${icon}rust-analyzer`; } |
