on master help sign in
LSP: No-op client/registerCapability requests (#6258)
commit4f066b1cc628e2d3c69da9bdd0b16f1a8e74ce6f authorMichael Davis <mcarsondavis@gmail.com> dateSun 12 Mar 2023, 19:29 (4 years ago) parent1126af5
2 files changed+16
helix-lsp/src/lib.rs+5 helix-term/src/application.rs+11
helix-lsp/src/lib.rs+5
@@ -526,6 +526,7 @@ pub enum MethodCall {
526526 ApplyWorkspaceEdit(lsp::ApplyWorkspaceEditParams),
527527 WorkspaceFolders,
528528 WorkspaceConfiguration(lsp::ConfigurationParams),
529+ RegisterCapability(lsp::RegistrationParams),
529530}
530531
531532impl MethodCall {
@@ -545,6 +546,10 @@ impl MethodCall {
545546 let params: lsp::ConfigurationParams = params.parse()?;
546547 Self::WorkspaceConfiguration(params)
547548 }
549+ lsp::request::RegisterCapability::METHOD => {
550+ let params: lsp::RegistrationParams = params.parse()?;
551+ Self::RegisterCapability(params)
552+ }
548553 _ => {
549554 return Err(Error::Unhandled);
550555 }
helix-term/src/application.rs+11
@@ -1014,6 +1014,17 @@ impl Application {
10141014 .collect();
10151015 Ok(json!(result))
10161016 }
1017+ Ok(MethodCall::RegisterCapability(_params)) => {
1018+ log::warn!("Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server");
1019+ // Language Servers based on the `vscode-languageserver-node` library often send
1020+ // client/registerCapability even though we do not enable dynamic registration
1021+ // for any capabilities. We should send a MethodNotFound JSONRPC error in this
1022+ // case but that rejects the registration promise in the server which causes an
1023+ // exit. So we work around this by ignoring the request and sending back an OK
1024+ // response.
1025+
1026+ Ok(serde_json::Value::Null)
1027+ }
10171028 };
10181029
10191030 let language_server = match self.editor.language_servers.get_by_id(server_id) {