mirror of
https://github.com/neovim/neovim.git
synced 2026-10-26 15:40:20 -05:00
fix(lsp): guard dynamic capability attachment #38382
Problem: The capability attach path for client/registerCapability can initialize a capability even when the capability was only registered in specific buffers Solution: Check supports_method() before attaching capabilities from the dynamic registration handler so unsupported registrations are ignored. AI-assisted: OpenCode
This commit is contained in:
1 parent
24714c0d43
commit
a8ffa6e323
1 file changed
+4
-1
@@ -157,7 +157,10 @@ RSC['client/registerCapability'] = function(_, params, ctx)
|
||||
for _, Cap in pairs(vim.lsp._capability.all) do
|
||||
if reg.method == Cap.method then
|
||||
for bufnr in pairs(client.attached_buffers) do
|
||||
if vim.lsp._capability.is_enabled(Cap.name, { bufnr = bufnr, client_id = client.id }) then
|
||||
if
|
||||
client:supports_method(Cap.method, bufnr)
|
||||
and vim.lsp._capability.is_enabled(Cap.name, { bufnr = bufnr, client_id = client.id })
|
||||
then
|
||||
local capability = Cap.active[bufnr] or Cap:new(bufnr)
|
||||
if not capability.client_state[client.id] then
|
||||
capability:on_attach(client.id)
|
||||
|
||||
Reference in new issue
Block a user