mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 20:05:38 +00:00
feat(lsp): support auto-force escalation in client stop #36430
(cherry picked from commit 02cd564896)
This commit is contained in:
@@ -1208,42 +1208,8 @@ api.nvim_create_autocmd('VimLeavePre', {
|
||||
client:stop()
|
||||
end
|
||||
|
||||
local timeouts = {} --- @type table<integer,integer>
|
||||
local max_timeout = 0
|
||||
local send_kill = false
|
||||
|
||||
for client_id, client in pairs(active_clients) do
|
||||
local timeout = client.flags.exit_timeout
|
||||
if timeout then
|
||||
send_kill = true
|
||||
timeouts[client_id] = timeout
|
||||
max_timeout = math.max(timeout, max_timeout)
|
||||
end
|
||||
end
|
||||
|
||||
local poll_time = 50
|
||||
|
||||
local function check_clients_closed()
|
||||
for client_id, timeout in pairs(timeouts) do
|
||||
timeouts[client_id] = timeout - poll_time
|
||||
end
|
||||
|
||||
for client_id, _ in pairs(active_clients) do
|
||||
if timeouts[client_id] ~= nil and timeouts[client_id] > 0 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if send_kill then
|
||||
if not vim.wait(max_timeout, check_clients_closed, poll_time) then
|
||||
for client_id, client in pairs(active_clients) do
|
||||
if timeouts[client_id] ~= nil then
|
||||
client:stop(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, client in pairs(active_clients) do
|
||||
client:stop(client.flags.exit_timeout)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user