From 7d33b0f74a2399629e1d09a2c3fa1f32145ca1e3 Mon Sep 17 00:00:00 2001 From: Guilherme Rodz Date: Sun, 6 Feb 2022 18:30:46 -0300 Subject: [PATCH] fix: Delete a file as an open buffer (#939) --- lua/nvim-tree/actions/remove-file.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/actions/remove-file.lua b/lua/nvim-tree/actions/remove-file.lua index d1a18211..c52b2cb3 100644 --- a/lua/nvim-tree/actions/remove-file.lua +++ b/lua/nvim-tree/actions/remove-file.lua @@ -16,8 +16,8 @@ local function clear_buffer(absolute_path) vim.cmd(':bn') a.nvim_set_current_win(winnr) end - vim.api.nvim_buf_delete(buf.bufnr, {}) - if buf.windows[1] then + vim.api.nvim_buf_delete(buf.bufnr, { force = true }) + if buf.windows[1] and vim.api.nvim_win_is_valid(buf.bufnr) then vim.api.nvim_win_close(buf.windows[1], true) end return