LSP: No-op client/registerCapability requests (#6258)

pull/6292/head
Michael Davis 2 years ago committed by GitHub
parent 1126af53b4
commit 4f066b1cc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -526,6 +526,7 @@ pub enum MethodCall {
ApplyWorkspaceEdit(lsp::ApplyWorkspaceEditParams), ApplyWorkspaceEdit(lsp::ApplyWorkspaceEditParams),
WorkspaceFolders, WorkspaceFolders,
WorkspaceConfiguration(lsp::ConfigurationParams), WorkspaceConfiguration(lsp::ConfigurationParams),
RegisterCapability(lsp::RegistrationParams),
} }
impl MethodCall { impl MethodCall {
@ -545,6 +546,10 @@ impl MethodCall {
let params: lsp::ConfigurationParams = params.parse()?; let params: lsp::ConfigurationParams = params.parse()?;
Self::WorkspaceConfiguration(params) Self::WorkspaceConfiguration(params)
} }
lsp::request::RegisterCapability::METHOD => {
let params: lsp::RegistrationParams = params.parse()?;
Self::RegisterCapability(params)
}
_ => { _ => {
return Err(Error::Unhandled); return Err(Error::Unhandled);
} }

@ -1014,6 +1014,17 @@ impl Application {
.collect(); .collect();
Ok(json!(result)) Ok(json!(result))
} }
Ok(MethodCall::RegisterCapability(_params)) => {
log::warn!("Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server");
// Language Servers based on the `vscode-languageserver-node` library often send
// client/registerCapability even though we do not enable dynamic registration
// for any capabilities. We should send a MethodNotFound JSONRPC error in this
// case but that rejects the registration promise in the server which causes an
// exit. So we work around this by ignoring the request and sending back an OK
// response.
Ok(serde_json::Value::Null)
}
}; };
let language_server = match self.editor.language_servers.get_by_id(server_id) { let language_server = match self.editor.language_servers.get_by_id(server_id) {

Loading…
Cancel
Save