mirror of
https://github.com/dense-analysis/ale.git
synced 2026-07-30 03:42:52 +08:00
Handle nil result in pull diagnostic handler (#5147)
- A stale or cancelled textDocument/diagnostic request can be answered with a nil result and no error, which is valid per the LSP specification. Guard against it so the handler does nothing rather than indexing the nil result.
This commit is contained in:
@@ -444,4 +444,31 @@ describe("ale.lsp.start", function()
|
||||
},
|
||||
}, vim_fn_calls)
|
||||
end)
|
||||
|
||||
it("should ignore pull model diagnostics with a nil result", function()
|
||||
lsp.start({name = "server:/code"})
|
||||
|
||||
eq(1, #start_calls)
|
||||
|
||||
local handlers = start_calls[1][1].handlers
|
||||
|
||||
eq("function", type(handlers["textDocument/diagnostic"]))
|
||||
|
||||
-- A stale request can be answered with a nil result and no error,
|
||||
-- which is valid per the LSP specification. The handler should do
|
||||
-- nothing rather than index the nil result.
|
||||
handlers["textDocument/diagnostic"](
|
||||
nil,
|
||||
nil,
|
||||
{
|
||||
params = {
|
||||
textDocument = {
|
||||
uri = "file://code/foo.py",
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
eq({}, vim_fn_calls)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user