1 import * as vscode from 'vscode';
3 const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
5 export class StatusDisplay implements vscode.Disposable {
6 public packageName?: string;
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 public handleProgressNotification(params: ProgressParams) {
61 const { token, value } = params;
62 if (token !== "rustAnalyzer/cargoWatcher") {
66 console.log("Got progress notification", token, value)
74 this.packageName = value.message;
85 return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
89 // FIXME: Replace this once vscode-languageclient is updated to LSP 3.15
90 interface ProgressParams {
92 value: WorkDoneProgress
95 enum WorkDoneProgressKind {
101 interface WorkDoneProgress {
102 kind: WorkDoneProgressKind,