Add cargo-watch package animation and refactoring

This commit is contained in:
Edwin Cheng 2019-04-03 01:46:47 +08:00
parent 5cdf525caa
commit 88bcaf0e18
2 changed files with 78 additions and 44 deletions

View file

@ -3,6 +3,8 @@ import * as vscode from 'vscode';
const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
export class StatusDisplay {
public packageName?: string;
private i = 0;
private statusBarItem: vscode.StatusBarItem;
private timer?: NodeJS.Timeout;
@ -17,10 +19,18 @@ export class StatusDisplay {
}
public show() {
this.packageName = undefined;
this.timer =
this.timer ||
setInterval(() => {
this.statusBarItem!.text = 'cargo check ' + this.frame();
if (this.packageName) {
this.statusBarItem!.text = `cargo check [${
this.packageName
}] ${this.frame()}`;
} else {
this.statusBarItem!.text = `cargo check ${this.frame()}`;
}
}, 300);
this.statusBarItem!.show();