mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
fix(diagnostic): resolve buffer number in get() (#16407)
This commit is contained in:
@@ -395,6 +395,7 @@ local function get_diagnostics(bufnr, opts, clamp)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif namespace == nil then
|
elseif namespace == nil then
|
||||||
|
bufnr = get_bufnr(bufnr)
|
||||||
for iter_namespace in pairs(diagnostic_cache[bufnr]) do
|
for iter_namespace in pairs(diagnostic_cache[bufnr]) do
|
||||||
for _, diagnostic in pairs(diagnostic_cache[bufnr][iter_namespace]) do
|
for _, diagnostic in pairs(diagnostic_cache[bufnr][iter_namespace]) do
|
||||||
add(diagnostic)
|
add(diagnostic)
|
||||||
@@ -407,6 +408,7 @@ local function get_diagnostics(bufnr, opts, clamp)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
bufnr = get_bufnr(bufnr)
|
||||||
for _, diagnostic in pairs(diagnostic_cache[bufnr][namespace] or {}) do
|
for _, diagnostic in pairs(diagnostic_cache[bufnr][namespace] or {}) do
|
||||||
add(diagnostic)
|
add(diagnostic)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -128,6 +128,17 @@ describe('vim.diagnostic', function()
|
|||||||
eq('Diagnostic #1', result[1].message)
|
eq('Diagnostic #1', result[1].message)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('resolves buffer number 0 to the current buffer', function()
|
||||||
|
eq(2, exec_lua [[
|
||||||
|
vim.api.nvim_set_current_buf(diagnostic_bufnr)
|
||||||
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
|
||||||
|
make_error('Diagnostic #1', 1, 1, 1, 1),
|
||||||
|
make_error('Diagnostic #2', 2, 1, 2, 1),
|
||||||
|
})
|
||||||
|
return #vim.diagnostic.get(0)
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it('saves and count a single error', function()
|
it('saves and count a single error', function()
|
||||||
eq(1, exec_lua [[
|
eq(1, exec_lua [[
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
|
||||||
|
|||||||
Reference in New Issue
Block a user