mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
fix(lsp): check if client is stopping before reuse #33796
Problem: Stopping a language server and then calling vim.lsp.start() with the same name/root will return the old language server that's in the middle of shutting down. vim.lsp.start() won't return a new server until the old process has terminated. Solution: Introducing a client._is_stopping field that tracks the shutdown phase, preventing the client from being reused.
This commit is contained in:
@@ -218,6 +218,25 @@ describe('LSP', function()
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
||||
it('does not reuse an already-stopping client #33616', function()
|
||||
-- we immediately try to start a second client with the same name/root
|
||||
-- before the first one has finished shutting down; we must get a new id.
|
||||
local clients = exec_lua([[
|
||||
local client1 = vim.lsp.start({
|
||||
name = 'dup-test',
|
||||
cmd = { vim.v.progpath, '-l', fake_lsp_code, 'basic_init' },
|
||||
}, { attach = false })
|
||||
vim.lsp.get_client_by_id(client1):stop()
|
||||
local client2 = vim.lsp.start({
|
||||
name = 'dup-test',
|
||||
cmd = { vim.v.progpath, '-l', fake_lsp_code, 'basic_init' },
|
||||
}, { attach = false })
|
||||
return { client1, client2 }
|
||||
]])
|
||||
local c1, c2 = clients[1], clients[2]
|
||||
eq(false, c1 == c2, 'Expected a fresh client while the old one is stopping')
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('basic_init test', function()
|
||||
|
Reference in New Issue
Block a user