fix(lsp): use client.id instead of pairs index (#29143)

Problem: Completion side effects not working randomly.

Solution: When creating the table of LSP responses, the table index
was used, but this is not the same as the actual client_id, so it was changed
to use the client_id directly.
This commit is contained in:
ippachi 2024-06-04 01:07:09 +09:00 committed by GitHub
parent a9c89bcbf6
commit 5aa9906676
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -349,7 +349,7 @@ function M._convert_results(
return matches, server_start_boundary return matches, server_start_boundary
end end
--- @param clients table<integer, vim.lsp.Client> --- @param clients table<integer, vim.lsp.Client> # keys != client_id
--- @param bufnr integer --- @param bufnr integer
--- @param win integer --- @param win integer
--- @param callback fun(responses: table<integer, { err: lsp.ResponseError, result: vim.lsp.CompletionResult }>) --- @param callback fun(responses: table<integer, { err: lsp.ResponseError, result: vim.lsp.CompletionResult }>)
@ -359,7 +359,8 @@ local function request(clients, bufnr, win, callback)
local request_ids = {} --- @type table<integer, integer> local request_ids = {} --- @type table<integer, integer>
local remaining_requests = vim.tbl_count(clients) local remaining_requests = vim.tbl_count(clients)
for client_id, client in pairs(clients) do for _, client in pairs(clients) do
local client_id = client.id
local params = lsp.util.make_position_params(win, client.offset_encoding) local params = lsp.util.make_position_params(win, client.offset_encoding)
local ok, request_id = client.request(ms.textDocument_completion, params, function(err, result) local ok, request_id = client.request(ms.textDocument_completion, params, function(err, result)
responses[client_id] = { err = err, result = result } responses[client_id] = { err = err, result = result }