Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code] Wait for shutdown to complete before we start the client again. #719

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
the scheduler for the visible area of the document; combined with
the new lazy checking mode, this provides checking on scroll, a
feature inspired from Isabelle IDE (@ejgallego, #717)
- Have VSCode wait for full LSP client shutdown on server restart
(@ejgallgo, #719)

# coq-lsp 0.1.8.1: Spring fix
-----------------------------
Expand Down
53 changes: 27 additions & 26 deletions editor/code/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function activateCoqLSP(
return settings;
}

function coqCommand(command: string, fn: () => void) {
function coqCommand(command: string, fn: () => void | Promise<void>) {
let disposable = commands.registerCommand("coq-lsp." + command, fn);
context.subscriptions.push(disposable);
}
Expand Down Expand Up @@ -165,7 +165,7 @@ export function activateCoqLSP(

const stop = () => {
if (client && client.isRunning()) {
client
return client
.dispose(2000)
.finally(updateStatusBar)
.finally(() => {
Expand All @@ -174,7 +174,7 @@ export function activateCoqLSP(
perfDataHook.dispose();
heatMap.dispose();
});
}
} else return Promise.resolve();
};

const start = () => {
Expand Down Expand Up @@ -204,35 +204,36 @@ export function activateCoqLSP(
resolve(client);
});

cP.then((client) =>
client
.start()
.then(updateStatusBar)
.then(() => {
if (window.activeTextEditor) {
goalsCall(
window.activeTextEditor,
TextEditorSelectionChangeKind.Command
);
}
})
).catch((error) => {
let emsg = error.toString();
console.log(`Error in coq-lsp start: ${emsg}`);
setFailedStatuBar(emsg);
});
return cP
.then((client) =>
client
.start()
.then(updateStatusBar)
.then(() => {
if (window.activeTextEditor) {
goalsCall(
window.activeTextEditor,
TextEditorSelectionChangeKind.Command
);
}
})
)
.catch((error) => {
let emsg = error.toString();
console.log(`Error in coq-lsp start: ${emsg}`);
setFailedStatuBar(emsg);
});
};

const restart = () => {
stop();
start();
const restart = async () => {
await stop().finally(start);
};

const toggle = () => {
const toggle = async () => {
if (client && client.isRunning()) {
stop();
await stop();
} else {
start();
await start();
}
};

Expand Down
Loading