about summary refs log tree commit diff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-15 11:38:44 +0000
committerbors <bors@rust-lang.org>2023-08-15 11:38:44 +0000
commitef2ee59631f9a0f62ff03b54befdef363675ceed (patch)
treea7d94f8da704a95e9f58a98d26cef7c85d92a8e3 /editors/code/src/ctx.ts
parentb771de3fdc1d0eed102336c2f76ca6ced07656ac (diff)
parente76d20e072cd25ca2df21ef51e973bf666f4c840 (diff)
downloadrust-ef2ee59631f9a0f62ff03b54befdef363675ceed.tar.gz
rust-ef2ee59631f9a0f62ff03b54befdef363675ceed.zip
Auto merge of #15446 - Veykril:checkOnSaveToggle, r=Veykril
Add status bar button to toggle check on save state

Closes https://github.com/rust-lang/rust-analyzer/issues/15440
cc https://github.com/rust-lang/rust-analyzer/issues/13208
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts18
1 files changed, 16 insertions, 2 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 16c14ca54f2..363a7a82e68 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -94,6 +94,7 @@ export class Ctx {
     private unlinkedFiles: vscode.Uri[];
     private _dependencies: RustDependenciesProvider | undefined;
     private _treeView: vscode.TreeView<Dependency | DependencyFile | DependencyId> | undefined;
+    private lastStatus: ServerStatusParams | { health: "stopped" } = { health: "stopped" };
 
     get client() {
         return this._client;
@@ -404,7 +405,15 @@ export class Ctx {
     }
 
     setServerStatus(status: ServerStatusParams | { health: "stopped" }) {
+        this.lastStatus = status;
+        this.updateStatusBarItem();
+    }
+    refreshServerStatus() {
+        this.updateStatusBarItem();
+    }
+    private updateStatusBarItem() {
         let icon = "";
+        const status = this.lastStatus;
         const statusBar = this.statusBar;
         statusBar.show();
         statusBar.tooltip = new vscode.MarkdownString("", true);
@@ -447,13 +456,18 @@ export class Ctx {
                     "statusBarItem.warningBackground",
                 );
                 statusBar.command = "rust-analyzer.startServer";
-                statusBar.text = `$(stop-circle) rust-analyzer`;
+                statusBar.text = "$(stop-circle) rust-analyzer";
                 return;
         }
         if (statusBar.tooltip.value) {
             statusBar.tooltip.appendMarkdown("\n\n---\n\n");
         }
-        statusBar.tooltip.appendMarkdown("\n\n[Open logs](command:rust-analyzer.openLogs)");
+        statusBar.tooltip.appendMarkdown("\n\n[Open Logs](command:rust-analyzer.openLogs)");
+        statusBar.tooltip.appendMarkdown(
+            `\n\n[${
+                this.config.checkOnSave ? "Disable" : "Enable"
+            } Check on Save](command:rust-analyzer.toggleCheckOnSave)`,
+        );
         statusBar.tooltip.appendMarkdown(
             "\n\n[Reload Workspace](command:rust-analyzer.reloadWorkspace)",
         );