mirror of
https://github.com/neovim/neovim.git
synced 2026-05-01 11:34:56 +00:00
fix(diagnostic): preserve fields from LSP diagnostics via user_data (#15735)
* preserve fields from LSP diagnostics via adding a user_data table to the diagnostic, which can hold arbitrary data in addition to the lsp diagnostic information.
This commit is contained in:
@@ -428,6 +428,32 @@ describe('vim.lsp.diagnostic', function()
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
it('maintains LSP information when translating diagnostics', function()
|
||||
local result = exec_lua [[
|
||||
local diagnostics = {
|
||||
make_error("Error 1", 1, 1, 1, 5),
|
||||
}
|
||||
|
||||
diagnostics[1].code = 42
|
||||
diagnostics[1].tags = {"foo", "bar"}
|
||||
diagnostics[1].data = "Hello world"
|
||||
|
||||
vim.lsp.diagnostic.on_publish_diagnostics(nil, {
|
||||
uri = fake_uri,
|
||||
diagnostics = diagnostics,
|
||||
}, {client_id=1})
|
||||
|
||||
return {
|
||||
vim.diagnostic.get(diagnostic_bufnr, {lnum=1})[1],
|
||||
vim.lsp.diagnostic.get_line_diagnostics(diagnostic_bufnr, 1)[1],
|
||||
}
|
||||
]]
|
||||
eq({code = 42, tags = {"foo", "bar"}, data = "Hello world"}, result[1].user_data.lsp)
|
||||
eq(42, result[2].code)
|
||||
eq({"foo", "bar"}, result[2].tags)
|
||||
eq("Hello world", result[2].data)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("vim.lsp.diagnostic.get_line_diagnostics", function()
|
||||
|
||||
Reference in New Issue
Block a user