1 import * as vscode from 'vscode';
3 const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
5 export class StatusDisplay implements vscode.Disposable {
9 private statusBarItem: vscode.StatusBarItem;
10 private command: string;
11 private timer?: NodeJS.Timeout;
13 constructor(command: string) {
14 this.statusBarItem = vscode.window.createStatusBarItem(
15 vscode.StatusBarAlignment.Left,
18 this.command = command;
19 this.statusBarItem.hide();
23 this.packageName = undefined;
28 if (this.packageName) {
29 this.statusBarItem!.text = `cargo ${this.command} [${
33 this.statusBarItem!.text = `cargo ${
39 this.statusBarItem.show();
44 clearInterval(this.timer);
45 this.timer = undefined;
48 this.statusBarItem.hide();
53 clearInterval(this.timer);
54 this.timer = undefined;
57 this.statusBarItem.dispose();
60 handleProgressNotification(params: ProgressParams) {
61 const { token, value } = params;
62 if (token !== 'rustAnalyzer/cargoWatcher') {
73 this.packageName = value.message;
84 return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
88 // FIXME: Replace this once vscode-languageclient is updated to LSP 3.15
89 interface ProgressParams {
91 value: WorkDoneProgress;
94 enum WorkDoneProgressKind {
100 interface WorkDoneProgress {
101 kind: WorkDoneProgressKind;
103 cancelable?: boolean;