aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/src/inlay_hints.ts24
1 files changed, 11 insertions, 13 deletions
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index 7b9dcfb22..161b34037 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -9,9 +9,7 @@ export function activateInlayHints(ctx: Ctx) {
9 const hintsUpdater = new HintsUpdater(ctx.client); 9 const hintsUpdater = new HintsUpdater(ctx.client);
10 10
11 vscode.window.onDidChangeVisibleTextEditors( 11 vscode.window.onDidChangeVisibleTextEditors(
12 visibleEditors => hintsUpdater.refreshVisibleRustEditors( 12 () => hintsUpdater.refreshVisibleRustEditors(),
13 visibleEditors.filter(isRustTextEditor)
14 ),
15 null, 13 null,
16 ctx.subscriptions 14 ctx.subscriptions
17 ); 15 );
@@ -21,7 +19,7 @@ export function activateInlayHints(ctx: Ctx) {
21 if (contentChanges.length === 0) return; 19 if (contentChanges.length === 0) return;
22 if (!isRustTextDocument(document)) return; 20 if (!isRustTextDocument(document)) return;
23 21
24 hintsUpdater.refreshRustDocument(document); 22 hintsUpdater.forceRefreshVisibleRustEditors();
25 }, 23 },
26 null, 24 null,
27 ctx.subscriptions 25 ctx.subscriptions
@@ -92,7 +90,7 @@ class HintsUpdater {
92 this.enabled = enabled; 90 this.enabled = enabled;
93 91
94 if (this.enabled) { 92 if (this.enabled) {
95 this.refreshVisibleRustEditors(vscode.window.visibleTextEditors.filter(isRustTextEditor)); 93 this.refreshVisibleRustEditors();
96 } else { 94 } else {
97 this.clearHints(); 95 this.clearHints();
98 } 96 }
@@ -105,20 +103,20 @@ class HintsUpdater {
105 } 103 }
106 } 104 }
107 105
108 refreshRustDocument(document: RustTextDocument) { 106 forceRefreshVisibleRustEditors() {
109 if (!this.enabled) return; 107 if (!this.enabled) return;
110 108
111 const file = this.sourceFiles.getSourceFile(document.uri.toString()); 109 for (const file of this.sourceFiles) {
112 110 void file.fetchAndRenderHints(this.client);
113 assert(!!file, "Document must be opened in some text editor!"); 111 }
114
115 void file.fetchAndRenderHints(this.client);
116 } 112 }
117 113
118 refreshVisibleRustEditors(visibleEditors: RustTextEditor[]) { 114 refreshVisibleRustEditors() {
119 if (!this.enabled) return; 115 if (!this.enabled) return;
120 116
121 const visibleSourceFiles = this.sourceFiles.drainEditors(visibleEditors); 117 const visibleSourceFiles = this.sourceFiles.drainEditors(
118 vscode.window.visibleTextEditors.filter(isRustTextEditor)
119 );
122 120
123 // Cancel requests for source files whose editors were disposed (leftovers after drain). 121 // Cancel requests for source files whose editors were disposed (leftovers after drain).
124 for (const { inlaysRequest } of this.sourceFiles) inlaysRequest?.cancel(); 122 for (const { inlaysRequest } of this.sourceFiles) inlaysRequest?.cancel();