From d000c56373f5a11cbc0a7aa2cdfff503528e9f0f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Aug 2024 19:53:48 +0800 Subject: [PATCH] fix(man): check if buffer is valid before restoring 'tagfunc' (#30180) (cherry picked from commit 7588ff2d8986e343d440dc8e025b1b5d4d8974b5) --- runtime/lua/man.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index e5ed82e248..33136d61e2 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -714,7 +714,7 @@ function M.open_page(count, smods, args) end sect, name = extract_sect_and_name_path(path) - local buf = fn.bufnr() + local buf = api.nvim_get_current_buf() local save_tfu = vim.bo[buf].tagfunc vim.bo[buf].tagfunc = "v:lua.require'man'.goto_tag" @@ -730,7 +730,9 @@ function M.open_page(count, smods, args) end end) - vim.bo[buf].tagfunc = save_tfu + if api.nvim_buf_is_valid(buf) then + vim.bo[buf].tagfunc = save_tfu + end if not ok then error(ret)