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.ts23
1 files changed, 19 insertions, 4 deletions
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index 3896878cd..55bbd7f00 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -27,9 +27,15 @@ export function activateInlayHints(ctx: Ctx) {
27 ctx.subscriptions 27 ctx.subscriptions
28 ); 28 );
29 29
30 // We pass async function though it will not be awaited when called, 30 ctx.pushCleanup({
31 // thus Promise rejections won't be handled, but this should never throw in fact... 31 dispose() {
32 ctx.onDidRestart(async _ => hintsUpdater.setEnabled(ctx.config.displayInlayHints)); 32 hintsUpdater.clear()
33 }
34 })
35
36 // XXX: we don't await this, thus Promise rejections won't be handled, but
37 // this should never throw in fact...
38 hintsUpdater.setEnabled(ctx.config.displayInlayHints)
33} 39}
34 40
35interface InlayHintsParams { 41interface InlayHintsParams {
@@ -61,16 +67,23 @@ class HintsUpdater {
61 67
62 constructor(ctx: Ctx) { 68 constructor(ctx: Ctx) {
63 this.ctx = ctx; 69 this.ctx = ctx;
64 this.enabled = ctx.config.displayInlayHints; 70 this.enabled = false;
65 } 71 }
66 72
67 async setEnabled(enabled: boolean): Promise<void> { 73 async setEnabled(enabled: boolean): Promise<void> {
74 console.log({ enabled, prev: this.enabled });
75
68 if (this.enabled == enabled) return; 76 if (this.enabled == enabled) return;
69 this.enabled = enabled; 77 this.enabled = enabled;
70 78
71 if (this.enabled) { 79 if (this.enabled) {
72 return await this.refresh(); 80 return await this.refresh();
81 } else {
82 return this.clear();
73 } 83 }
84 }
85
86 clear() {
74 this.allEditors.forEach(it => { 87 this.allEditors.forEach(it => {
75 this.setTypeDecorations(it, []); 88 this.setTypeDecorations(it, []);
76 this.setParameterDecorations(it, []); 89 this.setParameterDecorations(it, []);
@@ -79,6 +92,8 @@ class HintsUpdater {
79 92
80 async refresh() { 93 async refresh() {
81 if (!this.enabled) return; 94 if (!this.enabled) return;
95 console.log("freshin!");
96
82 await Promise.all(this.allEditors.map(it => this.refreshEditor(it))); 97 await Promise.all(this.allEditors.map(it => this.refreshEditor(it)));
83 } 98 }
84 99