diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-01 15:41:55 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-01 15:41:55 +0000 |
commit | 3f499489f79d05f8cc31b72055155e91bc78fddc (patch) | |
tree | 170c625c712b602c912ffb516ffdc9594818f547 /editors/code | |
parent | eba599d9863553d0f7d9d93f4c9050943da171cc (diff) | |
parent | d4d72e8b9b3cc8b9ce72444a11e16cfa606a7f59 (diff) |
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 <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/status_display.ts | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts index c75fddf9d..7345bc3f5 100644 --- a/editors/code/src/status_display.ts +++ b/editors/code/src/status_display.ts | |||
@@ -17,7 +17,7 @@ export function activateStatusDisplay(ctx: Ctx) { | |||
17 | class StatusDisplay implements vscode.Disposable { | 17 | class StatusDisplay implements vscode.Disposable { |
18 | packageName?: string; | 18 | packageName?: string; |
19 | 19 | ||
20 | private i = 0; | 20 | private i: number = 0; |
21 | private statusBarItem: vscode.StatusBarItem; | 21 | private statusBarItem: vscode.StatusBarItem; |
22 | private command: string; | 22 | private command: string; |
23 | private timer?: NodeJS.Timeout; | 23 | private timer?: NodeJS.Timeout; |
@@ -37,11 +37,8 @@ class StatusDisplay implements vscode.Disposable { | |||
37 | this.timer = | 37 | this.timer = |
38 | this.timer || | 38 | this.timer || |
39 | setInterval(() => { | 39 | setInterval(() => { |
40 | if (this.packageName) { | 40 | this.tick(); |
41 | this.statusBarItem!.text = `${this.frame()} cargo ${this.command} [${this.packageName}]`; | 41 | this.refreshLabel(); |
42 | } else { | ||
43 | this.statusBarItem!.text = `${this.frame()} cargo ${this.command}`; | ||
44 | } | ||
45 | }, 300); | 42 | }, 300); |
46 | 43 | ||
47 | this.statusBarItem.show(); | 44 | this.statusBarItem.show(); |
@@ -65,6 +62,14 @@ class StatusDisplay implements vscode.Disposable { | |||
65 | this.statusBarItem.dispose(); | 62 | this.statusBarItem.dispose(); |
66 | } | 63 | } |
67 | 64 | ||
65 | refreshLabel() { | ||
66 | if (this.packageName) { | ||
67 | this.statusBarItem!.text = `${spinnerFrames[this.i]} cargo ${this.command} [${this.packageName}]`; | ||
68 | } else { | ||
69 | this.statusBarItem!.text = `${spinnerFrames[this.i]} cargo ${this.command}`; | ||
70 | } | ||
71 | } | ||
72 | |||
68 | handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) { | 73 | handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) { |
69 | switch (params.kind) { | 74 | switch (params.kind) { |
70 | case 'begin': | 75 | case 'begin': |
@@ -74,6 +79,7 @@ class StatusDisplay implements vscode.Disposable { | |||
74 | case 'report': | 79 | case 'report': |
75 | if (params.message) { | 80 | if (params.message) { |
76 | this.packageName = params.message; | 81 | this.packageName = params.message; |
82 | this.refreshLabel(); | ||
77 | } | 83 | } |
78 | break; | 84 | break; |
79 | 85 | ||
@@ -83,7 +89,7 @@ class StatusDisplay implements vscode.Disposable { | |||
83 | } | 89 | } |
84 | } | 90 | } |
85 | 91 | ||
86 | private frame() { | 92 | private tick() { |
87 | return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)]; | 93 | this.i = (this.i + 1) % spinnerFrames.length; |
88 | } | 94 | } |
89 | } | 95 | } |