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