-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Exiting during LSP initialization fixed #5850
Conversation
Thanks for contributing! In the The right fix is to always send exit notifications and shutdown requests when the server is not initialized. Simply add a special conditions in The reason we should shutdown too is that we are actually kind of racing the server initalization here so the server might finish initialization before we know about.
With that change to the pub async fn shutdown_and_exit(&self) -> Result<()> {
if let Err(e) = self.shutdown().await {
// if the server is still initalizing it will return -32002 in that case it's save to send exit() directly
if self.initalized && matches!(e, Err(Error::Rpc(jsonrpc::Error{code: jsonrpc::ErrorCode::ServerError(-32002), ..) {
return Err(e);
}
}
self.shutdown().await?;
} |
Ah actually reading further in the spec I am not quite sure if this is the correct solution afterall:
That means we could send an Nothing we can really do about this I believe. So helix is behaving correctly here, might be interesting to look into what other editors in this case tough. |
See microsoft/language-server-protocol#246 pretty sure this is a current limitation of the LSP spec and there is nothing we can do about this. |
This is fixed in #7449: now we follow neovim's behavior and kill the language server when shutting down during initialization. |
Quick fix for issue #5732, by sending exit notification to language servers that are not yet initialized.