diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/rollup.config.js | 2 | ||||
-rw-r--r-- | editors/code/src/inlay_hints.ts | 2 | ||||
-rw-r--r-- | editors/code/src/status_display.ts | 36 |
3 files changed, 9 insertions, 31 deletions
diff --git a/editors/code/rollup.config.js b/editors/code/rollup.config.js index 14fb9e085..de6a3b2b7 100644 --- a/editors/code/rollup.config.js +++ b/editors/code/rollup.config.js | |||
@@ -13,7 +13,7 @@ export default { | |||
13 | commonjs({ | 13 | commonjs({ |
14 | namedExports: { | 14 | namedExports: { |
15 | // squelch missing import warnings | 15 | // squelch missing import warnings |
16 | 'vscode-languageclient': ['CreateFile', 'RenameFile', 'ErrorCodes'] | 16 | 'vscode-languageclient': ['CreateFile', 'RenameFile', 'ErrorCodes', 'WorkDoneProgress', 'WorkDoneProgressBegin', 'WorkDoneProgressReport', 'WorkDoneProgressEnd'] |
17 | } | 17 | } |
18 | }) | 18 | }) |
19 | ], | 19 | ], |
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index c4206cf5b..6357e44f1 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts | |||
@@ -42,7 +42,7 @@ const parameterHintDecorationType = vscode.window.createTextEditorDecorationType | |||
42 | before: { | 42 | before: { |
43 | color: new vscode.ThemeColor('rust_analyzer.inlayHint'), | 43 | color: new vscode.ThemeColor('rust_analyzer.inlayHint'), |
44 | } | 44 | } |
45 | }) | 45 | }); |
46 | 46 | ||
47 | class HintsUpdater { | 47 | class HintsUpdater { |
48 | private pending: Map<string, vscode.CancellationTokenSource> = new Map(); | 48 | private pending: Map<string, vscode.CancellationTokenSource> = new Map(); |
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 | } | ||