mirror of
https://github.com/neovim/neovim
synced 2025-07-18 18:21:46 +00:00
fix(diagnostic): only update decorations for loaded buffers (#15715)
When vim.diagnostic.config() is called, the decorations for diagnostics are re-displayed to use the new configuration. This should only be done for loaded buffers.
This commit is contained in:
@ -544,14 +544,16 @@ function M.config(opts, namespace)
|
|||||||
|
|
||||||
if namespace then
|
if namespace then
|
||||||
for bufnr, v in pairs(diagnostic_cache) do
|
for bufnr, v in pairs(diagnostic_cache) do
|
||||||
if v[namespace] then
|
if vim.api.nvim_buf_is_loaded(bufnr) and v[namespace] then
|
||||||
M.show(namespace, bufnr)
|
M.show(namespace, bufnr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for bufnr, v in pairs(diagnostic_cache) do
|
for bufnr, v in pairs(diagnostic_cache) do
|
||||||
for ns in pairs(v) do
|
if vim.api.nvim_buf_is_loaded(bufnr) then
|
||||||
M.show(ns, bufnr)
|
for ns in pairs(v) do
|
||||||
|
M.show(ns, bufnr)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -589,12 +591,10 @@ function M.set(namespace, bufnr, diagnostics, opts)
|
|||||||
|
|
||||||
set_diagnostic_cache(namespace, diagnostics, bufnr)
|
set_diagnostic_cache(namespace, diagnostics, bufnr)
|
||||||
|
|
||||||
if opts then
|
|
||||||
M.config(opts, namespace)
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.api.nvim_buf_is_loaded(bufnr) then
|
if vim.api.nvim_buf_is_loaded(bufnr) then
|
||||||
M.show(namespace, bufnr)
|
M.show(namespace, bufnr, diagnostics, opts)
|
||||||
|
elseif opts then
|
||||||
|
M.config(opts, namespace)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged")
|
vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged")
|
||||||
|
Reference in New Issue
Block a user