@@ -21,7 +21,10 @@ const typeHintDecorationType = vscode.window.createTextEditorDecorationType({
21
21
22
22
export class HintsUpdater {
23
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
29
public async loadHints ( editor ?: vscode . TextEditor ) : Promise < void > {
27
30
if ( this . displayHints ) {
@@ -48,7 +51,7 @@ export class HintsUpdater {
48
51
public async toggleHintsDisplay ( displayHints : boolean ) : Promise < void > {
49
52
if ( this . displayHints !== displayHints ) {
50
53
this . displayHints = displayHints ;
51
- this . drawnDecorations . clear ( ) ;
54
+ this . drawnDecorations = new WeakMap ( ) ;
52
55
53
56
if ( displayHints ) {
54
57
return this . updateHints ( ) ;
@@ -77,21 +80,18 @@ export class HintsUpdater {
77
80
return ;
78
81
}
79
82
80
- return await this . updateDecorationsFromServer (
81
- document . uri . toString ( ) ,
82
- editor
83
- ) ;
83
+ return await this . updateDecorationsFromServer ( document . uri , editor ) ;
84
84
}
85
85
86
86
private isRustDocument ( document : vscode . TextDocument ) : boolean {
87
87
return document && document . languageId === 'rust' ;
88
88
}
89
89
90
90
private async updateDecorationsFromServer (
91
- documentUri : string ,
91
+ documentUri : vscode . Uri ,
92
92
editor : TextEditor
93
93
) : Promise < void > {
94
- const newHints = await this . queryHints ( documentUri ) ;
94
+ const newHints = await this . queryHints ( documentUri . toString ( ) ) ;
95
95
if ( newHints != null ) {
96
96
const newDecorations = newHints . map ( hint => ( {
97
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
133
if ( editor && this . isRustDocument ( editor . document ) ) {
132
- return editor . document . uri . toString ( ) ;
134
+ return editor . document . uri ;
133
135
}
134
136
return null ;
135
137
}
0 commit comments