diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/main.ts | 3 | ||||
-rw-r--r-- | editors/code/src/status_display.ts | 100 |
2 files changed, 0 insertions, 103 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a92c676fa..16a94fceb 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -5,7 +5,6 @@ import { promises as fs, PathLike } from "fs"; | |||
5 | 5 | ||
6 | import * as commands from './commands'; | 6 | import * as commands from './commands'; |
7 | import { activateInlayHints } from './inlay_hints'; | 7 | import { activateInlayHints } from './inlay_hints'; |
8 | import { activateStatusDisplay } from './status_display'; | ||
9 | import { Ctx } from './ctx'; | 8 | import { Ctx } from './ctx'; |
10 | import { Config, NIGHTLY_TAG } from './config'; | 9 | import { Config, NIGHTLY_TAG } from './config'; |
11 | import { log, assert, isValidExecutable } from './util'; | 10 | import { log, assert, isValidExecutable } from './util'; |
@@ -103,8 +102,6 @@ export async function activate(context: vscode.ExtensionContext) { | |||
103 | 102 | ||
104 | ctx.pushCleanup(activateTaskProvider(workspaceFolder)); | 103 | ctx.pushCleanup(activateTaskProvider(workspaceFolder)); |
105 | 104 | ||
106 | activateStatusDisplay(ctx); | ||
107 | |||
108 | activateInlayHints(ctx); | 105 | activateInlayHints(ctx); |
109 | 106 | ||
110 | vscode.workspace.onDidChangeConfiguration( | 107 | vscode.workspace.onDidChangeConfiguration( |
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts deleted file mode 100644 index f9cadc8a2..000000000 --- a/editors/code/src/status_display.ts +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd, Disposable } from 'vscode-languageclient'; | ||
4 | |||
5 | import { Ctx } from './ctx'; | ||
6 | |||
7 | const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; | ||
8 | |||
9 | export function activateStatusDisplay(ctx: Ctx) { | ||
10 | const statusDisplay = new StatusDisplay(ctx.config.checkOnSave.command); | ||
11 | ctx.pushCleanup(statusDisplay); | ||
12 | const client = ctx.client; | ||
13 | if (client != null) { | ||
14 | ctx.pushCleanup(client.onProgress( | ||
15 | WorkDoneProgress.type, | ||
16 | 'rustAnalyzer/cargoWatcher', | ||
17 | params => statusDisplay.handleProgressNotification(params) | ||
18 | )); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | class StatusDisplay implements Disposable { | ||
23 | packageName?: string; | ||
24 | |||
25 | private i: number = 0; | ||
26 | private statusBarItem: vscode.StatusBarItem; | ||
27 | private command: string; | ||
28 | private timer?: NodeJS.Timeout; | ||
29 | |||
30 | constructor(command: string) { | ||
31 | this.statusBarItem = vscode.window.createStatusBarItem( | ||
32 | vscode.StatusBarAlignment.Left, | ||
33 | 10, | ||
34 | ); | ||
35 | this.command = command; | ||
36 | this.statusBarItem.hide(); | ||
37 | } | ||
38 | |||
39 | show() { | ||
40 | this.packageName = undefined; | ||
41 | |||
42 | this.timer = | ||
43 | this.timer || | ||
44 | setInterval(() => { | ||
45 | this.tick(); | ||
46 | this.refreshLabel(); | ||
47 | }, 300); | ||
48 | |||
49 | this.statusBarItem.show(); | ||
50 | } | ||
51 | |||
52 | hide() { | ||
53 | if (this.timer) { | ||
54 | clearInterval(this.timer); | ||
55 | this.timer = undefined; | ||
56 | } | ||
57 | |||
58 | this.statusBarItem.hide(); | ||
59 | } | ||
60 | |||
61 | dispose() { | ||
62 | if (this.timer) { | ||
63 | clearInterval(this.timer); | ||
64 | this.timer = undefined; | ||
65 | } | ||
66 | |||
67 | this.statusBarItem.dispose(); | ||
68 | } | ||
69 | |||
70 | refreshLabel() { | ||
71 | if (this.packageName) { | ||
72 | this.statusBarItem.text = `${spinnerFrames[this.i]} cargo ${this.command} [${this.packageName}]`; | ||
73 | } else { | ||
74 | this.statusBarItem.text = `${spinnerFrames[this.i]} cargo ${this.command}`; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) { | ||
79 | switch (params.kind) { | ||
80 | case 'begin': | ||
81 | this.show(); | ||
82 | break; | ||
83 | |||
84 | case 'report': | ||
85 | if (params.message) { | ||
86 | this.packageName = params.message; | ||
87 | this.refreshLabel(); | ||
88 | } | ||
89 | break; | ||
90 | |||
91 | case 'end': | ||
92 | this.hide(); | ||
93 | break; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | private tick() { | ||
98 | this.i = (this.i + 1) % spinnerFrames.length; | ||
99 | } | ||
100 | } | ||