diff options
author | Aleksey Kladov <[email protected]> | 2019-12-30 19:16:07 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-30 19:16:07 +0000 |
commit | 6cc55e4c5ce994be284fc4337eed21844c0eef24 (patch) | |
tree | 608e6434d077bef30e2f5832cb3d8c10d2831305 /editors/code/src/commands | |
parent | 7b199f6a4b7a947d1dad6a74b2b88758497d4efa (diff) |
status is not a command
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/watch_status.ts | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/editors/code/src/commands/watch_status.ts b/editors/code/src/commands/watch_status.ts deleted file mode 100644 index 10787b510..000000000 --- a/editors/code/src/commands/watch_status.ts +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; | ||
4 | |||
5 | export class StatusDisplay implements vscode.Disposable { | ||
6 | public packageName?: string; | ||
7 | |||
8 | private i = 0; | ||
9 | private statusBarItem: vscode.StatusBarItem; | ||
10 | private command: string; | ||
11 | private timer?: NodeJS.Timeout; | ||
12 | |||
13 | constructor(command: string) { | ||
14 | this.statusBarItem = vscode.window.createStatusBarItem( | ||
15 | vscode.StatusBarAlignment.Left, | ||
16 | 10, | ||
17 | ); | ||
18 | this.command = command; | ||
19 | this.statusBarItem.hide(); | ||
20 | } | ||
21 | |||
22 | public show() { | ||
23 | this.packageName = undefined; | ||
24 | |||
25 | this.timer = | ||
26 | this.timer || | ||
27 | setInterval(() => { | ||
28 | if (this.packageName) { | ||
29 | this.statusBarItem!.text = `cargo ${this.command} [${ | ||
30 | this.packageName | ||
31 | }] ${this.frame()}`; | ||
32 | } else { | ||
33 | this.statusBarItem!.text = `cargo ${ | ||
34 | this.command | ||
35 | } ${this.frame()}`; | ||
36 | } | ||
37 | }, 300); | ||
38 | |||
39 | this.statusBarItem.show(); | ||
40 | } | ||
41 | |||
42 | public hide() { | ||
43 | if (this.timer) { | ||
44 | clearInterval(this.timer); | ||
45 | this.timer = undefined; | ||
46 | } | ||
47 | |||
48 | this.statusBarItem.hide(); | ||
49 | } | ||
50 | |||
51 | public dispose() { | ||
52 | if (this.timer) { | ||
53 | clearInterval(this.timer); | ||
54 | this.timer = undefined; | ||
55 | } | ||
56 | |||
57 | this.statusBarItem.dispose(); | ||
58 | } | ||
59 | |||
60 | public handleProgressNotification(params: ProgressParams) { | ||
61 | const { token, value } = params; | ||
62 | if (token !== 'rustAnalyzer/cargoWatcher') { | ||
63 | return; | ||
64 | } | ||
65 | |||
66 | switch (value.kind) { | ||
67 | case 'begin': | ||
68 | this.show(); | ||
69 | break; | ||
70 | |||
71 | case 'report': | ||
72 | if (value.message) { | ||
73 | this.packageName = value.message; | ||
74 | } | ||
75 | break; | ||
76 | |||
77 | case 'end': | ||
78 | this.hide(); | ||
79 | break; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | private frame() { | ||
84 | return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)]; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | // FIXME: Replace this once vscode-languageclient is updated to LSP 3.15 | ||
89 | interface ProgressParams { | ||
90 | token: string; | ||
91 | value: WorkDoneProgress; | ||
92 | } | ||
93 | |||
94 | enum WorkDoneProgressKind { | ||
95 | Begin = 'begin', | ||
96 | Report = 'report', | ||
97 | End = 'end', | ||
98 | } | ||
99 | |||
100 | interface WorkDoneProgress { | ||
101 | kind: WorkDoneProgressKind; | ||
102 | message?: string; | ||
103 | cancelable?: boolean; | ||
104 | percentage?: string; | ||
105 | } | ||