mirror of
https://github.com/neovim/neovim.git
synced 2025-12-18 04:15:44 +00:00
feat(lsp): support version in textDocument/publishDiagnostics #36754
This commit makes it so that push diagnostics received for an outdated document version are ignored.
This commit is contained in:
@@ -148,6 +148,40 @@ describe('vim.lsp.diagnostic', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('ignores outdated diagnostics', function()
|
||||
local result = exec_lua(function()
|
||||
vim.lsp.diagnostic.on_publish_diagnostics(nil, {
|
||||
uri = fake_uri,
|
||||
version = vim.lsp.util.buf_versions[diagnostic_bufnr] - 1,
|
||||
diagnostics = {
|
||||
_G.make_error('Error', 0, 0, 1, 0),
|
||||
},
|
||||
}, { client_id = client_id })
|
||||
|
||||
local diags = vim.diagnostic.get(diagnostic_bufnr)
|
||||
return diags
|
||||
end)
|
||||
|
||||
-- Ignored: outdated version.
|
||||
eq(0, #result)
|
||||
|
||||
result = exec_lua(function()
|
||||
vim.lsp.diagnostic.on_publish_diagnostics(nil, {
|
||||
uri = fake_uri,
|
||||
version = vim.lsp.util.buf_versions[diagnostic_bufnr],
|
||||
diagnostics = {
|
||||
_G.make_error('Error', 0, 0, 1, 0),
|
||||
},
|
||||
}, { client_id = client_id })
|
||||
|
||||
local diags = vim.diagnostic.get(diagnostic_bufnr)
|
||||
return diags
|
||||
end)
|
||||
|
||||
-- Applied: up-to-date version.
|
||||
eq(1, #result)
|
||||
end)
|
||||
|
||||
it('does not create buffer on empty diagnostics', function()
|
||||
-- No buffer is created without diagnostics
|
||||
eq(
|
||||
|
||||
Reference in New Issue
Block a user