Skip to content

Commit 027804b

Browse files
Improve LSP shutdown behaviour (#20)
1 parent f08318f commit 027804b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"publisher": "Imandra",
77
"icon": "assets/vscode-imandra-avatar.png",
88
"license": "MIT",
9-
"version": "0.0.11",
9+
"version": "0.0.12",
1010
"repository": {
1111
"type": "git",
1212
"url": "https://github.com/imandra-ai/imandrax-vscode"

src/extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ export async function start() {
176176
}
177177

178178
// Sleep for the number of seconds
179-
async function sleep(time_s: number) {
180-
return new Promise(resolve => setTimeout(resolve, time_s * 1000));
179+
async function sleep(time_ms: number) {
180+
return new Promise(resolve => setTimeout(resolve, time_ms));
181181
}
182182

183183
export function restart(initial: boolean = false): Thenable<void> | undefined {
@@ -186,9 +186,13 @@ export function restart(initial: boolean = false): Thenable<void> | undefined {
186186
else {
187187
clientRestarts += 1;
188188
console.log(`Restarting Imandrax LSP server (attempt ${clientRestarts})`);
189+
client.sendRequest("shutdown", null); // Try to shut down gracefully.
189190
client.stop();
191+
190192
window.activeTextEditor.setDecorations(decoration_type_good, []);
191193
window.activeTextEditor.setDecorations(decoration_type_bad, []);
194+
195+
sleep(500); // Give it a bit of time to avoid races on the log file.
192196
}
193197
return start();
194198
}
@@ -198,6 +202,7 @@ export function deactivate(): Thenable<void> | undefined {
198202
return undefined;
199203
}
200204
console.log("Deactivating ImandraX LSP server");
205+
client.sendRequest("shutdown", null);
201206
const c = client;
202207
client = null;
203208
return c.stop();

0 commit comments

Comments
 (0)