diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/inlay_hints.ts | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index fd7c49c89..e1a82e03e 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts | |||
@@ -13,7 +13,7 @@ export function activateInlayHints(ctx: Ctx) { | |||
13 | if (!ctx.config.displayInlayHints) { | 13 | if (!ctx.config.displayInlayHints) { |
14 | return this.dispose(); | 14 | return this.dispose(); |
15 | } | 15 | } |
16 | if (!this.updater) this.updater = HintsUpdater.create(ctx); | 16 | if (!this.updater) this.updater = new HintsUpdater(ctx); |
17 | }, | 17 | }, |
18 | dispose() { | 18 | dispose() { |
19 | this.updater?.dispose(); | 19 | this.updater?.dispose(); |
@@ -67,25 +67,21 @@ class HintsUpdater implements Disposable { | |||
67 | private sourceFiles = new Map<string, RustSourceFile>(); // map Uri -> RustSourceFile | 67 | private sourceFiles = new Map<string, RustSourceFile>(); // map Uri -> RustSourceFile |
68 | private readonly disposables: Disposable[] = []; | 68 | private readonly disposables: Disposable[] = []; |
69 | 69 | ||
70 | private constructor(private readonly ctx: Ctx) { } | 70 | constructor(private readonly ctx: Ctx) { |
71 | |||
72 | static create(ctx: Ctx) { | ||
73 | const self = new HintsUpdater(ctx); | ||
74 | |||
75 | vscode.window.onDidChangeVisibleTextEditors( | 71 | vscode.window.onDidChangeVisibleTextEditors( |
76 | self.onDidChangeVisibleTextEditors, | 72 | this.onDidChangeVisibleTextEditors, |
77 | self, | 73 | this, |
78 | self.disposables | 74 | this.disposables |
79 | ); | 75 | ); |
80 | 76 | ||
81 | vscode.workspace.onDidChangeTextDocument( | 77 | vscode.workspace.onDidChangeTextDocument( |
82 | self.onDidChangeTextDocument, | 78 | this.onDidChangeTextDocument, |
83 | self, | 79 | this, |
84 | self.disposables | 80 | this.disposables |
85 | ); | 81 | ); |
86 | 82 | ||
87 | // Set up initial cache shape | 83 | // Set up initial cache shape |
88 | ctx.visibleRustEditors.forEach(editor => self.sourceFiles.set( | 84 | ctx.visibleRustEditors.forEach(editor => this.sourceFiles.set( |
89 | editor.document.uri.toString(), | 85 | editor.document.uri.toString(), |
90 | { | 86 | { |
91 | document: editor.document, | 87 | document: editor.document, |
@@ -94,9 +90,7 @@ class HintsUpdater implements Disposable { | |||
94 | } | 90 | } |
95 | )); | 91 | )); |
96 | 92 | ||
97 | self.syncCacheAndRenderHints(); | 93 | this.syncCacheAndRenderHints(); |
98 | |||
99 | return self; | ||
100 | } | 94 | } |
101 | 95 | ||
102 | dispose() { | 96 | dispose() { |