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

Co-authored-by: Jesse <github@jessebakker.com>
(cherry picked from commit 29c72cdf4a)
This commit is contained in:
Gregory Anders
2024-12-02 12:13:23 -06:00
committed by GitHub
parent e80e8a0980
commit 308e9719cf
7 changed files with 122 additions and 8 deletions

View File

@@ -945,6 +945,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 },
},
}
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 } },
@@ -964,7 +997,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