Skip to content

Commit 07f59e7

Browse files
authored
fix(#1539): Fix closing nvim-tree float when file is removed (#1546)
* Fix closing nvim-tree float when file is removed * Revert changes for non-float Co-authored-by: Krzysztof Cieśla <[email protected]>
1 parent 4a725c0 commit 07f59e7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ local luv = vim.loop
33

44
local utils = require "nvim-tree.utils"
55
local events = require "nvim-tree.events"
6+
local view = require "nvim-tree.view"
67

78
local M = {}
89

910
local function close_windows(windows)
11+
if view.View.float.enable and #a.nvim_list_wins() == 1 then
12+
return
13+
end
14+
1015
for _, window in ipairs(windows) do
1116
if a.nvim_win_is_valid(window) then
1217
a.nvim_win_close(window, true)
@@ -18,11 +23,13 @@ local function clear_buffer(absolute_path)
1823
local bufs = vim.fn.getbufinfo { bufloaded = 1, buflisted = 1 }
1924
for _, buf in pairs(bufs) do
2025
if buf.name == absolute_path then
21-
if buf.hidden == 0 and #bufs > 1 then
26+
if buf.hidden == 0 and (#bufs > 1 or view.View.float.enable) then
2227
local winnr = a.nvim_get_current_win()
2328
a.nvim_set_current_win(buf.windows[1])
2429
vim.cmd ":bn"
25-
a.nvim_set_current_win(winnr)
30+
if not view.View.float.enable then
31+
a.nvim_set_current_win(winnr)
32+
end
2633
end
2734
a.nvim_buf_delete(buf.bufnr, { force = true })
2835
if M.close_window then

0 commit comments

Comments
 (0)