Skip to content

Commit 65cecff

Browse files
author
Veetaha
committed
vscode: post refactor HintsUpdater (simplify create() -> constructor call)
1 parent 61a4ea2 commit 65cecff

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

editors/code/src/inlay_hints.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function activateInlayHints(ctx: Ctx) {
1313
if (!ctx.config.displayInlayHints) {
1414
return this.dispose();
1515
}
16-
if (!this.updater) this.updater = HintsUpdater.create(ctx);
16+
if (!this.updater) this.updater = new HintsUpdater(ctx);
1717
},
1818
dispose() {
1919
this.updater?.dispose();
@@ -67,25 +67,21 @@ class HintsUpdater implements Disposable {
6767
private sourceFiles = new Map<string, RustSourceFile>(); // map Uri -> RustSourceFile
6868
private readonly disposables: Disposable[] = [];
6969

70-
private constructor(private readonly ctx: Ctx) { }
71-
72-
static create(ctx: Ctx) {
73-
const self = new HintsUpdater(ctx);
74-
70+
constructor(private readonly ctx: Ctx) {
7571
vscode.window.onDidChangeVisibleTextEditors(
76-
self.onDidChangeVisibleTextEditors,
77-
self,
78-
self.disposables
72+
this.onDidChangeVisibleTextEditors,
73+
this,
74+
this.disposables
7975
);
8076

8177
vscode.workspace.onDidChangeTextDocument(
82-
self.onDidChangeTextDocument,
83-
self,
84-
self.disposables
78+
this.onDidChangeTextDocument,
79+
this,
80+
this.disposables
8581
);
8682

8783
// Set up initial cache shape
88-
ctx.visibleRustEditors.forEach(editor => self.sourceFiles.set(
84+
ctx.visibleRustEditors.forEach(editor => this.sourceFiles.set(
8985
editor.document.uri.toString(),
9086
{
9187
document: editor.document,
@@ -94,9 +90,7 @@ class HintsUpdater implements Disposable {
9490
}
9591
));
9692

97-
self.syncCacheAndRenderHints();
98-
99-
return self;
93+
this.syncCacheAndRenderHints();
10094
}
10195

10296
dispose() {

0 commit comments

Comments
 (0)