lsp: Check if "Goto Definition" supported before request (#15111)

This is related to #15023 where we have the running Rubocop LSP that
provides diagnostics and formatting capabilities. Rubocop LSP sends its
capabilities
back to Zed without support for "textDocument/definition" request, Zed
actually does not check that and sends a request to Rubocop that results
in the server error "Unsupported method: textDocument/definition".

The fix here is related to
https://github.com/zed-industries/zed/pull/14666

Release Notes:

- N/A
This commit is contained in:
Vitaly Slobodin 2024-07-24 22:28:23 +02:00 committed by GitHub
parent 740c444089
commit 9c9a0bd24f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -786,6 +786,7 @@ mod tests {
let mut cx = EditorLspTestContext::new_rust(
lsp::ServerCapabilities {
hover_provider: Some(lsp::HoverProviderCapability::Simple(true)),
definition_provider: Some(lsp::OneOf::Left(true)),
..Default::default()
},
cx,

View File

@ -427,6 +427,13 @@ impl LspCommand for GetDefinition {
type LspRequest = lsp::request::GotoDefinition;
type ProtoRequest = proto::GetDefinition;
fn check_capabilities(&self, capabilities: AdapterServerCapabilities) -> bool {
capabilities
.server_capabilities
.definition_provider
.is_some()
}
fn to_lsp(
&self,
path: &Path,