mirror of
https://github.com/neovim/neovim.git
synced 2026-07-17 06:31:16 +00: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:
@@ -157,7 +157,10 @@ RSC['client/registerCapability'] = function(_, params, ctx)
|
|||||||
for _, Cap in pairs(vim.lsp._capability.all) do
|
for _, Cap in pairs(vim.lsp._capability.all) do
|
||||||
if reg.method == Cap.method then
|
if reg.method == Cap.method then
|
||||||
for bufnr in pairs(client.attached_buffers) do
|
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)
|
local capability = Cap.active[bufnr] or Cap:new(bufnr)
|
||||||
if not capability.client_state[client.id] then
|
if not capability.client_state[client.id] then
|
||||||
capability:on_attach(client.id)
|
capability:on_attach(client.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user