fix(lsp): retrigger diagnostics request on server cancellation (#31345)

Co-authored-by: Jesse <github@jessebakker.com>
This commit is contained in:
Gregory Anders
2024-11-25 11:48:11 -06:00
committed by GitHub
parent 8d55cc218c
commit 29c72cdf4a
7 changed files with 120 additions and 5 deletions

View File

@@ -1066,6 +1066,39 @@ describe('LSP', function()
}
end)
it('should forward ServerCancelled to callback', function()
local expected_handlers = {
{ NIL, {}, { method = 'finish', client_id = 1 } },
{
{ code = -32802 },
NIL,
{ method = 'error_code_test', bufnr = 1, client_id = 1, version = 0 },
},
}
local client --- @type vim.lsp.Client
test_rpc_server {
test_name = 'check_forward_server_cancelled',
on_init = function(_client)
_client:request('error_code_test')
client = _client
end,
on_exit = function(code, signal)
eq(0, code, 'exit code')
eq(0, signal, 'exit signal')
eq(0, #expected_handlers, 'did not call expected handler')
end,
on_handler = function(err, _, ctx)
eq(table.remove(expected_handlers), { err, _, ctx }, 'expected handler')
if ctx.method ~= 'finish' then
client:notify('finish')
end
if ctx.method == 'finish' then
client:stop()
end
end,
}
end)
it('should forward ContentModified to callback', function()
local expected_handlers = {
{ NIL, {}, { method = 'finish', client_id = 1 } },
@@ -1089,7 +1122,6 @@ describe('LSP', function()
end,
on_handler = function(err, _, ctx)
eq(table.remove(expected_handlers), { err, _, ctx }, 'expected handler')
-- if ctx.method == 'error_code_test' then client.notify("finish") end
if ctx.method ~= 'finish' then
client:notify('finish')
end