From 84784a83913d12009b19649a7238369f7eca4c04 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 Dec 2021 07:35:46 -0700 Subject: [PATCH] fix(diagnostic): set effective buffer number for DiagnosticChanged autocmd (#16485) This enables use of in autocommand handlers for DiagnosticChanged. --- runtime/lua/vim/diagnostic.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 5c5631af98..71bf96baee 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -653,9 +653,11 @@ function M.set(namespace, bufnr, diagnostics, opts) M.show(namespace, bufnr, nil, opts) end - vim.api.nvim_command( - string.format("doautocmd DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr)) - ) + vim.api.nvim_buf_call(bufnr, function() + vim.api.nvim_command( + string.format("doautocmd DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr)) + ) + end) end --- Get namespace metadata.