From 6063e07a0f50855f3e8fad38f04cd1d7f6535443 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Wed, 8 Dec 2021 21:13:47 -0700 Subject: [PATCH] fix(diagnostic): set effective buffer number in autocmd (again) (#16589) Follow up to #16474. --- runtime/lua/vim/diagnostic.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index dfcac33f6d..59cb9f8c5b 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1344,12 +1344,14 @@ function M.reset(namespace, bufnr) end end - vim.api.nvim_command( - string.format( - "doautocmd DiagnosticChanged %s", - vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr)) + vim.api.nvim_buf_call(bufnr, function() + vim.api.nvim_command( + string.format( + "doautocmd DiagnosticChanged %s", + vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr)) + ) ) - ) + end) end --- Add all diagnostics to the quickfix list.