diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/commands/inlay_hints.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts index 11a2cfac5..aad28d564 100644 --- a/editors/code/src/commands/inlay_hints.ts +++ b/editors/code/src/commands/inlay_hints.ts | |||
@@ -21,7 +21,10 @@ const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ | |||
21 | 21 | ||
22 | export class HintsUpdater { | 22 | export class HintsUpdater { |
23 | private displayHints = true; | 23 | private displayHints = true; |
24 | private drawnDecorations = new Map<string, vscode.DecorationOptions[]>(); | 24 | private drawnDecorations = new WeakMap< |
25 | vscode.Uri, | ||
26 | vscode.DecorationOptions[] | ||
27 | >(); | ||
25 | 28 | ||
26 | public async loadHints(editor?: vscode.TextEditor): Promise<void> { | 29 | public async loadHints(editor?: vscode.TextEditor): Promise<void> { |
27 | if (this.displayHints) { | 30 | if (this.displayHints) { |
@@ -48,7 +51,7 @@ export class HintsUpdater { | |||
48 | public async toggleHintsDisplay(displayHints: boolean): Promise<void> { | 51 | public async toggleHintsDisplay(displayHints: boolean): Promise<void> { |
49 | if (this.displayHints !== displayHints) { | 52 | if (this.displayHints !== displayHints) { |
50 | this.displayHints = displayHints; | 53 | this.displayHints = displayHints; |
51 | this.drawnDecorations.clear(); | 54 | this.drawnDecorations = new WeakMap(); |
52 | 55 | ||
53 | if (displayHints) { | 56 | if (displayHints) { |
54 | return this.updateHints(); | 57 | return this.updateHints(); |
@@ -77,10 +80,7 @@ export class HintsUpdater { | |||
77 | return; | 80 | return; |
78 | } | 81 | } |
79 | 82 | ||
80 | return await this.updateDecorationsFromServer( | 83 | return await this.updateDecorationsFromServer(document.uri, editor); |
81 | document.uri.toString(), | ||
82 | editor | ||
83 | ); | ||
84 | } | 84 | } |
85 | 85 | ||
86 | private isRustDocument(document: vscode.TextDocument): boolean { | 86 | private isRustDocument(document: vscode.TextDocument): boolean { |
@@ -88,10 +88,10 @@ export class HintsUpdater { | |||
88 | } | 88 | } |
89 | 89 | ||
90 | private async updateDecorationsFromServer( | 90 | private async updateDecorationsFromServer( |
91 | documentUri: string, | 91 | documentUri: vscode.Uri, |
92 | editor: TextEditor | 92 | editor: TextEditor |
93 | ): Promise<void> { | 93 | ): Promise<void> { |
94 | const newHints = await this.queryHints(documentUri); | 94 | const newHints = await this.queryHints(documentUri.toString()); |
95 | if (newHints != null) { | 95 | if (newHints != null) { |
96 | const newDecorations = newHints.map(hint => ({ | 96 | const newDecorations = newHints.map(hint => ({ |
97 | range: hint.range, | 97 | range: hint.range, |
@@ -127,9 +127,11 @@ export class HintsUpdater { | |||
127 | ); | 127 | ); |
128 | } | 128 | } |
129 | 129 | ||
130 | private getEditorDocumentUri(editor?: vscode.TextEditor): string | null { | 130 | private getEditorDocumentUri( |
131 | editor?: vscode.TextEditor | ||
132 | ): vscode.Uri | null { | ||
131 | if (editor && this.isRustDocument(editor.document)) { | 133 | if (editor && this.isRustDocument(editor.document)) { |
132 | return editor.document.uri.toString(); | 134 | return editor.document.uri; |
133 | } | 135 | } |
134 | return null; | 136 | return null; |
135 | } | 137 | } |