project: Make textDocument/signatureHelp implementation lsp compliant (#40707)

The parameter label offsets are utf16 offsets, not utf8. Additionally we
now validate the language server output.

Closes https://github.com/zed-industries/zed/issues/40578

Companion bug on rust-analyzer side
https://github.com/rust-lang/rust-analyzer/pull/20876

Release Notes:

- Fixed `textDocument/signatureHelp` implementation not being LSP
compliant
This commit is contained in:
Lukas Wirth
2025-10-20 14:57:23 +00:00
committed by GitHub
parent 30f3152e65
commit 67b9d480b4
2 changed files with 104 additions and 38 deletions
+15 -3
View File
@@ -1834,13 +1834,20 @@ impl LspCommand for GetSignatureHelp {
message: Option<lsp::SignatureHelp>,
lsp_store: Entity<LspStore>,
_: Entity<Buffer>,
_: LanguageServerId,
id: LanguageServerId,
cx: AsyncApp,
) -> Result<Self::Response> {
let Some(message) = message else {
return Ok(None);
};
cx.update(|cx| SignatureHelp::new(message, Some(lsp_store.read(cx).languages.clone()), cx))
cx.update(|cx| {
SignatureHelp::new(
message,
Some(lsp_store.read(cx).languages.clone()),
Some(id),
cx,
)
})
}
fn to_proto(&self, project_id: u64, buffer: &Buffer) -> Self::ProtoRequest {
@@ -1900,7 +1907,12 @@ impl LspCommand for GetSignatureHelp {
.signature_help
.map(proto_to_lsp_signature)
.and_then(|signature| {
SignatureHelp::new(signature, Some(lsp_store.read(cx).languages.clone()), cx)
SignatureHelp::new(
signature,
Some(lsp_store.read(cx).languages.clone()),
None,
cx,
)
})
})
}