Skip to content

Commit ffca9bb

Browse files
committed
push client state change listener to subscriptions to ensure its cleaned up
1 parent d1a56dd commit ffca9bb

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

client/src/extension.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,23 @@ export function activate(context: ExtensionContext) {
114114
// compilation has finished, and the most reliable source for that is the LS
115115
// server, that already keeps track of when the compiler finishes in order to
116116
// other provide fresh diagnostics.
117-
client.onDidChangeState(({ newState }) => {
118-
if (newState === State.Running) {
119-
context.subscriptions.push(
120-
client.onNotification("rescript/compilationFinished", () => {
121-
if (inCodeAnalysisState.active === true) {
122-
customCommands.codeAnalysisWithReanalyze(
123-
inCodeAnalysisState.activatedFromDirectory,
124-
diagnosticsCollection,
125-
diagnosticsResultCodeActions
126-
);
127-
}
128-
})
129-
);
130-
}
131-
});
117+
context.subscriptions.push(
118+
client.onDidChangeState(({ newState }) => {
119+
if (newState === State.Running) {
120+
context.subscriptions.push(
121+
client.onNotification("rescript/compilationFinished", () => {
122+
if (inCodeAnalysisState.active === true) {
123+
customCommands.codeAnalysisWithReanalyze(
124+
inCodeAnalysisState.activatedFromDirectory,
125+
diagnosticsCollection,
126+
diagnosticsResultCodeActions
127+
);
128+
}
129+
})
130+
);
131+
}
132+
})
133+
);
132134

133135
return client;
134136
}

0 commit comments

Comments
 (0)