lsp: Handle dynamic registration of textDocument/documentLink (#57749)

`register_server_capabilities` / `unregister_server_capabilities` had no
arm for `textDocument/documentLink`, so when a server saw our
`documentLink.dynamicRegistration` capability and chose to register the
provider dynamically, the registration silently fell into the `unhandled
capability registration` warning. `document_link_provider` stayed
`None`, `GetDocumentLinks::check_capabilities` returned false, and no
`textDocument/documentLink` request was ever sent.

Follow-up to https://github.com/zed-industries/zed/pull/56011

Release Notes:

- N/A

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Shuhei Kadowaki 2026-05-27 03:11:44 +09:00 committed by GitHub
parent c551ec93b0
commit efacf30294
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13076,6 +13076,18 @@ impl LspStore {
});
notify_server_capabilities_updated(&server, cx);
}
"textDocument/documentLink" => {
if let Some(caps) = reg
.register_options
.map(serde_json::from_value)
.transpose()?
{
server.update_capabilities(|capabilities| {
capabilities.document_link_provider = Some(caps);
});
notify_server_capabilities_updated(&server, cx);
}
}
_ => log::warn!("unhandled capability registration: {reg:?}"),
}
}
@ -13279,6 +13291,12 @@ impl LspStore {
});
notify_server_capabilities_updated(&server, cx);
}
"textDocument/documentLink" => {
server.update_capabilities(|capabilities| {
capabilities.document_link_provider = None;
});
notify_server_capabilities_updated(&server, cx);
}
_ => log::warn!("unhandled capability unregistration: {unreg:?}"),
}
}