diff options
Diffstat (limited to 'editors/code/src/commands/inlay_hints.ts')
-rw-r--r-- | editors/code/src/commands/inlay_hints.ts | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts index 0dbdd94fb..ac7dcce60 100644 --- a/editors/code/src/commands/inlay_hints.ts +++ b/editors/code/src/commands/inlay_hints.ts | |||
@@ -15,8 +15,8 @@ interface InlayHint { | |||
15 | 15 | ||
16 | const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ | 16 | const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ |
17 | after: { | 17 | after: { |
18 | color: new vscode.ThemeColor('ralsp.inlayHint') | 18 | color: new vscode.ThemeColor('ralsp.inlayHint'), |
19 | } | 19 | }, |
20 | }); | 20 | }); |
21 | 21 | ||
22 | export class HintsUpdater { | 22 | export class HintsUpdater { |
@@ -26,13 +26,13 @@ export class HintsUpdater { | |||
26 | if (this.displayHints !== displayHints) { | 26 | if (this.displayHints !== displayHints) { |
27 | this.displayHints = displayHints; | 27 | this.displayHints = displayHints; |
28 | return this.refreshVisibleEditorsHints( | 28 | return this.refreshVisibleEditorsHints( |
29 | displayHints ? undefined : [] | 29 | displayHints ? undefined : [], |
30 | ); | 30 | ); |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | public async refreshHintsForVisibleEditors( | 34 | public async refreshHintsForVisibleEditors( |
35 | cause?: TextDocumentChangeEvent | 35 | cause?: TextDocumentChangeEvent, |
36 | ): Promise<void> { | 36 | ): Promise<void> { |
37 | if (!this.displayHints) { | 37 | if (!this.displayHints) { |
38 | return; | 38 | return; |
@@ -48,21 +48,21 @@ export class HintsUpdater { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | private async refreshVisibleEditorsHints( | 50 | private async refreshVisibleEditorsHints( |
51 | newDecorations?: vscode.DecorationOptions[] | 51 | newDecorations?: vscode.DecorationOptions[], |
52 | ) { | 52 | ) { |
53 | const promises: Array<Promise<void>> = []; | 53 | const promises: Array<Promise<void>> = []; |
54 | 54 | ||
55 | for (const rustEditor of vscode.window.visibleTextEditors.filter( | 55 | for (const rustEditor of vscode.window.visibleTextEditors.filter( |
56 | editor => this.isRustDocument(editor.document) | 56 | editor => this.isRustDocument(editor.document), |
57 | )) { | 57 | )) { |
58 | if (newDecorations !== undefined) { | 58 | if (newDecorations !== undefined) { |
59 | promises.push( | 59 | promises.push( |
60 | Promise.resolve( | 60 | Promise.resolve( |
61 | rustEditor.setDecorations( | 61 | rustEditor.setDecorations( |
62 | typeHintDecorationType, | 62 | typeHintDecorationType, |
63 | newDecorations | 63 | newDecorations, |
64 | ) | 64 | ), |
65 | ) | 65 | ), |
66 | ); | 66 | ); |
67 | } else { | 67 | } else { |
68 | promises.push(this.updateDecorationsFromServer(rustEditor)); | 68 | promises.push(this.updateDecorationsFromServer(rustEditor)); |
@@ -79,7 +79,7 @@ export class HintsUpdater { | |||
79 | } | 79 | } |
80 | 80 | ||
81 | private async updateDecorationsFromServer( | 81 | private async updateDecorationsFromServer( |
82 | editor: TextEditor | 82 | editor: TextEditor, |
83 | ): Promise<void> { | 83 | ): Promise<void> { |
84 | const newHints = await this.queryHints(editor.document.uri.toString()); | 84 | const newHints = await this.queryHints(editor.document.uri.toString()); |
85 | if (newHints !== null) { | 85 | if (newHints !== null) { |
@@ -87,20 +87,20 @@ export class HintsUpdater { | |||
87 | range: hint.range, | 87 | range: hint.range, |
88 | renderOptions: { | 88 | renderOptions: { |
89 | after: { | 89 | after: { |
90 | contentText: `: ${hint.label}` | 90 | contentText: `: ${hint.label}`, |
91 | } | 91 | }, |
92 | } | 92 | }, |
93 | })); | 93 | })); |
94 | return editor.setDecorations( | 94 | return editor.setDecorations( |
95 | typeHintDecorationType, | 95 | typeHintDecorationType, |
96 | newDecorations | 96 | newDecorations, |
97 | ); | 97 | ); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { | 101 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { |
102 | const request: InlayHintsParams = { | 102 | const request: InlayHintsParams = { |
103 | textDocument: { uri: documentUri } | 103 | textDocument: { uri: documentUri }, |
104 | }; | 104 | }; |
105 | const client = Server.client; | 105 | const client = Server.client; |
106 | return client | 106 | return client |
@@ -108,8 +108,8 @@ export class HintsUpdater { | |||
108 | .then(() => | 108 | .then(() => |
109 | client.sendRequest<InlayHint[] | null>( | 109 | client.sendRequest<InlayHint[] | null>( |
110 | 'rust-analyzer/inlayHints', | 110 | 'rust-analyzer/inlayHints', |
111 | request | 111 | request, |
112 | ) | 112 | ), |
113 | ); | 113 | ); |
114 | } | 114 | } |
115 | } | 115 | } |