diff options
Diffstat (limited to 'editors/code/src/status_display.ts')
-rw-r--r-- | editors/code/src/status_display.ts | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts index 371a2f3bb..c75fddf9d 100644 --- a/editors/code/src/status_display.ts +++ b/editors/code/src/status_display.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
2 | 2 | ||
3 | import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd } from 'vscode-languageclient'; | ||
4 | |||
3 | import { Ctx } from './ctx'; | 5 | import { Ctx } from './ctx'; |
4 | 6 | ||
5 | const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; | 7 | const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; |
@@ -8,7 +10,7 @@ export function activateStatusDisplay(ctx: Ctx) { | |||
8 | const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command); | 10 | const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command); |
9 | ctx.pushCleanup(statusDisplay); | 11 | ctx.pushCleanup(statusDisplay); |
10 | ctx.onDidRestart(client => { | 12 | ctx.onDidRestart(client => { |
11 | client.onNotification('$/progress', params => statusDisplay.handleProgressNotification(params)); | 13 | client.onProgress(WorkDoneProgress.type, 'rustAnalyzer/cargoWatcher', params => statusDisplay.handleProgressNotification(params)); |
12 | }); | 14 | }); |
13 | } | 15 | } |
14 | 16 | ||
@@ -63,20 +65,15 @@ class StatusDisplay implements vscode.Disposable { | |||
63 | this.statusBarItem.dispose(); | 65 | this.statusBarItem.dispose(); |
64 | } | 66 | } |
65 | 67 | ||
66 | handleProgressNotification(params: ProgressParams) { | 68 | handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) { |
67 | const { token, value } = params; | 69 | switch (params.kind) { |
68 | if (token !== 'rustAnalyzer/cargoWatcher') { | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | switch (value.kind) { | ||
73 | case 'begin': | 70 | case 'begin': |
74 | this.show(); | 71 | this.show(); |
75 | break; | 72 | break; |
76 | 73 | ||
77 | case 'report': | 74 | case 'report': |
78 | if (value.message) { | 75 | if (params.message) { |
79 | this.packageName = value.message; | 76 | this.packageName = params.message; |
80 | } | 77 | } |
81 | break; | 78 | break; |
82 | 79 | ||
@@ -90,22 +87,3 @@ class StatusDisplay implements vscode.Disposable { | |||
90 | return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)]; | 87 | return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)]; |
91 | } | 88 | } |
92 | } | 89 | } |
93 | |||
94 | // FIXME: Replace this once vscode-languageclient is updated to LSP 3.15 | ||
95 | interface ProgressParams { | ||
96 | token: string; | ||
97 | value: WorkDoneProgress; | ||
98 | } | ||
99 | |||
100 | enum WorkDoneProgressKind { | ||
101 | Begin = 'begin', | ||
102 | Report = 'report', | ||
103 | End = 'end', | ||
104 | } | ||
105 | |||
106 | interface WorkDoneProgress { | ||
107 | kind: WorkDoneProgressKind; | ||
108 | message?: string; | ||
109 | cancelable?: boolean; | ||
110 | percentage?: string; | ||
111 | } | ||