From de018d9ae3721e6cb8fcc663431cdc4162a563dd Mon Sep 17 00:00:00 2001 From: yyk Date: Tue, 23 Aug 2022 10:40:30 -0700 Subject: [PATCH] Fix invalid buffer in defer fn. (#221) --- lua/navigator/diagnostics.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index e8a728f..7ea659b 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -58,7 +58,10 @@ local function error_marker(result, ctx, config) if bufnr == nil then bufnr = vim.uri_to_bufnr(result.uri) end - local fname = api.nvim_buf_get_name(bufnr) + local success, fname = pcall(api.nvim_buf_get_name, bufnr) + if not success then + return + end local uri = vim.uri_from_fname(fname) if uri ~= result.uri then log('not same buf', ctx, result.uri, bufnr, vim.fn.bufnr())