fix(picker.lsp): schedule_wrap cancel functions and resume when no clients

This commit is contained in:
Folke Lemaitre 2025-01-22 21:11:11 +01:00
parent dfcf27e2a9
commit 6cbca8adff
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -112,13 +112,18 @@ function M.request(buf, method, params, cb)
local async = Async.running()
local cancel = {} ---@type fun()[]
async:on("abort", function()
for _, c in ipairs(cancel) do
c()
end
end)
async:on(
"abort",
vim.schedule_wrap(function()
vim.tbl_map(pcall, cancel)
cancel = {}
end)
)
vim.schedule(function()
local clients = M.get_clients(buf, method)
if vim.tbl_isempty(clients) then
return async:resume()
end
local remaining = #clients
for _, client in ipairs(clients) do
local p = params(client)