mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test(lsp): fix flaky basic_finish test again (#28041)
Problem: LSP basic_finish test modified in #27899 is flaky again after #28030. Solution: Run on_setup() immediately after setup using a before_init callback.
This commit is contained in:
parent
3f3c7299a1
commit
0c0be09eab
@ -105,6 +105,11 @@ local function fake_lsp_server_setup(test_name, timeout_ms, options, settings)
|
|||||||
uri = 'file://' .. vim.uv.cwd(),
|
uri = 'file://' .. vim.uv.cwd(),
|
||||||
name = 'test_folder',
|
name = 'test_folder',
|
||||||
}};
|
}};
|
||||||
|
before_init = function(params, config)
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.rpcrequest(1, "setup")
|
||||||
|
end)
|
||||||
|
end,
|
||||||
on_init = function(client, result)
|
on_init = function(client, result)
|
||||||
TEST_RPC_CLIENT = client
|
TEST_RPC_CLIENT = client
|
||||||
vim.rpcrequest(1, "init", result)
|
vim.rpcrequest(1, "init", result)
|
||||||
@ -173,6 +178,12 @@ function M.test_rpc_server(config)
|
|||||||
--- @type integer, integer
|
--- @type integer, integer
|
||||||
local code, signal
|
local code, signal
|
||||||
local function on_request(method, args)
|
local function on_request(method, args)
|
||||||
|
if method == 'setup' then
|
||||||
|
if config.on_setup then
|
||||||
|
config.on_setup()
|
||||||
|
end
|
||||||
|
return NIL
|
||||||
|
end
|
||||||
if method == 'init' then
|
if method == 'init' then
|
||||||
if config.on_init then
|
if config.on_init then
|
||||||
config.on_init(client, unpack(args))
|
config.on_init(client, unpack(args))
|
||||||
@ -193,8 +204,8 @@ function M.test_rpc_server(config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- TODO specify timeout?
|
-- TODO specify timeout?
|
||||||
-- run(on_request, on_notify, config.on_setup, 1000)
|
-- run(on_request, on_notify, nil, 1000)
|
||||||
run(on_request, on_notify, config.on_setup)
|
run(on_request, on_notify, nil)
|
||||||
if config.on_exit then
|
if config.on_exit then
|
||||||
config.on_exit(code, signal)
|
config.on_exit(code, signal)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user