mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix(lsp): include context for each client in multi-handler results (#34669)
This commit is contained in:
committed by
GitHub
parent
f0c0c24ed7
commit
6005bc68b2
@ -1331,7 +1331,7 @@ end
|
||||
--- a `client_id:result` map.
|
||||
---@return function cancel Function that cancels all requests.
|
||||
function lsp.buf_request_all(bufnr, method, params, handler)
|
||||
local results = {} --- @type table<integer,{err: lsp.ResponseError?, result: any}>
|
||||
local results = {} --- @type table<integer,{err: lsp.ResponseError?, result: any, context: lsp.HandlerContext}>
|
||||
local remaining --- @type integer?
|
||||
|
||||
local _, cancel = lsp.buf_request(bufnr, method, params, function(err, result, ctx, config)
|
||||
@ -1341,7 +1341,7 @@ function lsp.buf_request_all(bufnr, method, params, handler)
|
||||
end
|
||||
|
||||
-- The error key is deprecated and will be removed in 0.13
|
||||
results[ctx.client_id] = { err = err, error = err, result = result }
|
||||
results[ctx.client_id] = { err = err, error = err, result = result, context = ctx }
|
||||
remaining = remaining - 1
|
||||
|
||||
if remaining == 0 then
|
||||
|
@ -2,7 +2,7 @@
|
||||
error('Cannot require a meta file')
|
||||
|
||||
---@alias lsp.Handler fun(err: lsp.ResponseError?, result: any, context: lsp.HandlerContext, config?: table): ...any
|
||||
---@alias lsp.MultiHandler fun(results: table<integer,{err: lsp.ResponseError?, result: any}>, context: lsp.HandlerContext, config?: table): ...any
|
||||
---@alias lsp.MultiHandler fun(results: table<integer,{err: lsp.ResponseError?, result: any, context: lsp.HandlerContext}>, context: lsp.HandlerContext, config?: table): ...any
|
||||
|
||||
---@class lsp.HandlerContext
|
||||
---@field method string
|
||||
|
@ -1075,7 +1075,7 @@ end
|
||||
---@class vim.lsp.CodeActionResultEntry
|
||||
---@field err? lsp.ResponseError
|
||||
---@field result? (lsp.Command|lsp.CodeAction)[]
|
||||
---@field ctx lsp.HandlerContext
|
||||
---@field context lsp.HandlerContext
|
||||
|
||||
--- @class vim.lsp.buf.code_action.Opts
|
||||
--- @inlinedoc
|
||||
@ -1152,7 +1152,7 @@ local function on_code_action_results(results, opts)
|
||||
for _, result in pairs(results) do
|
||||
for _, action in pairs(result.result or {}) do
|
||||
if action_filter(action) then
|
||||
table.insert(actions, { action = action, ctx = result.ctx })
|
||||
table.insert(actions, { action = action, ctx = result.context })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1325,12 +1325,7 @@ function M.code_action(opts)
|
||||
end
|
||||
|
||||
return params
|
||||
end, function(results, ctx)
|
||||
for _, result in pairs(results) do
|
||||
---@cast result vim.lsp.CodeActionResultEntry
|
||||
result.ctx = ctx
|
||||
end
|
||||
|
||||
end, function(results)
|
||||
on_code_action_results(results, opts)
|
||||
end)
|
||||
end
|
||||
|
Reference in New Issue
Block a user