about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-01 15:41:55 +0000
committerGitHub <noreply@github.com>2020-02-01 15:41:55 +0000
commit3f499489f79d05f8cc31b72055155e91bc78fddc (patch)
tree170c625c712b602c912ffb516ffdc9594818f547 /editors/code/src
parenteba599d9863553d0f7d9d93f4c9050943da171cc (diff)
parentd4d72e8b9b3cc8b9ce72444a11e16cfa606a7f59 (diff)
downloadrust-3f499489f79d05f8cc31b72055155e91bc78fddc.tar.gz
rust-3f499489f79d05f8cc31b72055155e91bc78fddc.zip
Merge #2964
2964: Improve responsiveness of the cargo check status label r=matklad a=lnicola

This is still not ideal because the label displays the crate that was just checked, not the one that's currently being checked. But it should give the impression of being faster.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/status_display.ts22
1 files changed, 14 insertions, 8 deletions
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts
index c75fddf9d74..7345bc3f509 100644
--- a/editors/code/src/status_display.ts
+++ b/editors/code/src/status_display.ts
@@ -17,7 +17,7 @@ export function activateStatusDisplay(ctx: Ctx) {
 class StatusDisplay implements vscode.Disposable {
     packageName?: string;
 
-    private i = 0;
+    private i: number = 0;
     private statusBarItem: vscode.StatusBarItem;
     private command: string;
     private timer?: NodeJS.Timeout;
@@ -37,11 +37,8 @@ class StatusDisplay implements vscode.Disposable {
         this.timer =
             this.timer ||
             setInterval(() => {
-                if (this.packageName) {
-                    this.statusBarItem!.text = `${this.frame()} cargo ${this.command} [${this.packageName}]`;
-                } else {
-                    this.statusBarItem!.text = `${this.frame()} cargo ${this.command}`;
-                }
+                this.tick();
+                this.refreshLabel();
             }, 300);
 
         this.statusBarItem.show();
@@ -65,6 +62,14 @@ class StatusDisplay implements vscode.Disposable {
         this.statusBarItem.dispose();
     }
 
+    refreshLabel() {
+        if (this.packageName) {
+            this.statusBarItem!.text = `${spinnerFrames[this.i]} cargo ${this.command} [${this.packageName}]`;
+        } else {
+            this.statusBarItem!.text = `${spinnerFrames[this.i]} cargo ${this.command}`;
+        }
+    }
+
     handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) {
         switch (params.kind) {
             case 'begin':
@@ -74,6 +79,7 @@ class StatusDisplay implements vscode.Disposable {
             case 'report':
                 if (params.message) {
                     this.packageName = params.message;
+                    this.refreshLabel();
                 }
                 break;
 
@@ -83,7 +89,7 @@ class StatusDisplay implements vscode.Disposable {
         }
     }
 
-    private frame() {
-        return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
+    private tick() {
+        this.i = (this.i + 1) % spinnerFrames.length;
     }
 }