Skip to content

Commit 3f49948

Browse files
bors[bot]lnicola
andauthored
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]>
2 parents eba599d + d4d72e8 commit 3f49948

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

editors/code/src/status_display.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function activateStatusDisplay(ctx: Ctx) {
1717
class StatusDisplay implements vscode.Disposable {
1818
packageName?: string;
1919

20-
private i = 0;
20+
private i: number = 0;
2121
private statusBarItem: vscode.StatusBarItem;
2222
private command: string;
2323
private timer?: NodeJS.Timeout;
@@ -37,11 +37,8 @@ class StatusDisplay implements vscode.Disposable {
3737
this.timer =
3838
this.timer ||
3939
setInterval(() => {
40-
if (this.packageName) {
41-
this.statusBarItem!.text = `${this.frame()} cargo ${this.command} [${this.packageName}]`;
42-
} else {
43-
this.statusBarItem!.text = `${this.frame()} cargo ${this.command}`;
44-
}
40+
this.tick();
41+
this.refreshLabel();
4542
}, 300);
4643

4744
this.statusBarItem.show();
@@ -65,6 +62,14 @@ class StatusDisplay implements vscode.Disposable {
6562
this.statusBarItem.dispose();
6663
}
6764

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+
6873
handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) {
6974
switch (params.kind) {
7075
case 'begin':
@@ -74,6 +79,7 @@ class StatusDisplay implements vscode.Disposable {
7479
case 'report':
7580
if (params.message) {
7681
this.packageName = params.message;
82+
this.refreshLabel();
7783
}
7884
break;
7985

@@ -83,7 +89,7 @@ class StatusDisplay implements vscode.Disposable {
8389
}
8490
}
8591

86-
private frame() {
87-
return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
92+
private tick() {
93+
this.i = (this.i + 1) % spinnerFrames.length;
8894
}
8995
}

0 commit comments

Comments
 (0)