Skip to content

Commit 0c54fa2

Browse files
committed
fix: error when deleting opened file from floating window
1 parent 7e3c0be commit 0c54fa2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lua/nvim-tree/actions/fs/remove-file.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local M = {
99
}
1010

1111
local function close_windows(windows)
12-
if view.View.float.enable and #vim.api.nvim_list_wins() == 1 then
12+
if view.View.float.enable and #vim.api.nvim_list_wins() < 3 then
1313
return
1414
end
1515

@@ -24,15 +24,15 @@ local function clear_buffer(absolute_path)
2424
local bufs = vim.fn.getbufinfo { bufloaded = 1, buflisted = 1 }
2525
for _, buf in pairs(bufs) do
2626
if buf.name == absolute_path then
27+
local tree_winnr = vim.api.nvim_get_current_win()
2728
if buf.hidden == 0 and (#bufs > 1 or view.View.float.enable) then
28-
local winnr = vim.api.nvim_get_current_win()
2929
vim.api.nvim_set_current_win(buf.windows[1])
3030
vim.cmd ":bn"
31-
if not view.View.float.enable then
32-
vim.api.nvim_set_current_win(winnr)
33-
end
3431
end
3532
vim.api.nvim_buf_delete(buf.bufnr, { force = true })
33+
if not view.View.float.quit_on_focus_loss then
34+
vim.api.nvim_set_current_win(tree_winnr)
35+
end
3636
if M.config.actions.remove_file.close_window then
3737
close_windows(buf.windows)
3838
end

0 commit comments

Comments
 (0)