From 5aa9906676f3ad040b0ccb75eb5fd560def1e0ec Mon Sep 17 00:00:00 2001 From: ippachi Date: Tue, 4 Jun 2024 01:07:09 +0900 Subject: 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. --- runtime/lua/vim/lsp/completion.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index f8e17ae2f0..c9326a0681 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -349,7 +349,7 @@ function M._convert_results( return matches, server_start_boundary end ---- @param clients table +--- @param clients table # keys != client_id --- @param bufnr integer --- @param win integer --- @param callback fun(responses: table) @@ -359,7 +359,8 @@ local function request(clients, bufnr, win, callback) local request_ids = {} --- @type table 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 ok, request_id = client.request(ms.textDocument_completion, params, function(err, result) responses[client_id] = { err = err, result = result } -- cgit