fix: check for loaded buffers before deleting

This commit is contained in:
kiyan 2021-02-14 17:18:59 +01:00
parent c59831a5d1
commit 5b428c014a

View File

@ -82,8 +82,9 @@ function M.create(node)
end
local function clear_buffer(absolute_path)
dump(api.nvim_list_bufs())
for _, buf in pairs(api.nvim_list_bufs()) do
if api.nvim_buf_get_name(buf) == absolute_path then
if vim.fn.bufloaded(buf) == 1 and api.nvim_buf_get_name(buf) == absolute_path then
api.nvim_command(':bd! '..buf)
end
end