aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/inlay_hints.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/inlay_hints.ts')
-rw-r--r--editors/code/src/inlay_hints.ts14
1 files changed, 4 insertions, 10 deletions
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index 6871bc111..08d3a64a7 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -2,7 +2,7 @@ import * as vscode from 'vscode';
2import * as ra from './rust-analyzer-api'; 2import * as ra from './rust-analyzer-api';
3 3
4import { Ctx } from './ctx'; 4import { Ctx } from './ctx';
5import { log, sendRequestWithRetry } from './util'; 5import { log, sendRequestWithRetry, isRustDocument } from './util';
6 6
7export function activateInlayHints(ctx: Ctx) { 7export function activateInlayHints(ctx: Ctx) {
8 const hintsUpdater = new HintsUpdater(ctx); 8 const hintsUpdater = new HintsUpdater(ctx);
@@ -15,7 +15,7 @@ export function activateInlayHints(ctx: Ctx) {
15 vscode.workspace.onDidChangeTextDocument( 15 vscode.workspace.onDidChangeTextDocument(
16 async event => { 16 async event => {
17 if (event.contentChanges.length === 0) return; 17 if (event.contentChanges.length === 0) return;
18 if (event.document.languageId !== 'rust') return; 18 if (!isRustDocument(event.document)) return;
19 await hintsUpdater.refresh(); 19 await hintsUpdater.refresh();
20 }, 20 },
21 null, 21 null,
@@ -77,7 +77,7 @@ class HintsUpdater {
77 } 77 }
78 78
79 clear() { 79 clear() {
80 this.allEditors.forEach(it => { 80 this.ctx.visibleRustEditors.forEach(it => {
81 this.setTypeDecorations(it, []); 81 this.setTypeDecorations(it, []);
82 this.setParameterDecorations(it, []); 82 this.setParameterDecorations(it, []);
83 }); 83 });
@@ -85,13 +85,7 @@ class HintsUpdater {
85 85
86 async refresh() { 86 async refresh() {
87 if (!this.enabled) return; 87 if (!this.enabled) return;
88 await Promise.all(this.allEditors.map(it => this.refreshEditor(it))); 88 await Promise.all(this.ctx.visibleRustEditors.map(it => this.refreshEditor(it)));
89 }
90
91 private get allEditors(): vscode.TextEditor[] {
92 return vscode.window.visibleTextEditors.filter(
93 editor => editor.document.languageId === 'rust',
94 );
95 } 89 }
96 90
97 private async refreshEditor(editor: vscode.TextEditor): Promise<void> { 91 private async refreshEditor(editor: vscode.TextEditor): Promise<void> {