diff options
author | Gregory Anders <greg@gpanders.com> | 2021-09-18 15:01:03 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-18 14:01:03 -0700 |
commit | 924e8e4f2d88ee5c45e521e9f758b7c9f247a011 (patch) | |
tree | 204af49c5cf59727851ca81cb2fd8aebf6f2a0ea /runtime/lua/vim | |
parent | 77399184d7fc03b6b345b632b89e6fe7e5b46644 (diff) | |
download | rneovim-924e8e4f2d88ee5c45e521e9f758b7c9f247a011.tar.gz rneovim-924e8e4f2d88ee5c45e521e9f758b7c9f247a011.tar.bz2 rneovim-924e8e4f2d88ee5c45e521e9f758b7c9f247a011.zip |
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.
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 00e4301fa0..61311f2135 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -544,14 +544,16 @@ function M.config(opts, namespace) if namespace then 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) end end else for bufnr, v in pairs(diagnostic_cache) do - for ns in pairs(v) do - M.show(ns, bufnr) + if vim.api.nvim_buf_is_loaded(bufnr) then + for ns in pairs(v) do + M.show(ns, bufnr) + end end end end @@ -589,12 +591,10 @@ function M.set(namespace, bufnr, diagnostics, opts) set_diagnostic_cache(namespace, diagnostics, bufnr) - if opts then - M.config(opts, namespace) - end - 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 vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged") |