Skip to content

Commit 018a078

Browse files
authored
fix(#3187): prevent closing the last non-floating window when deleting files (#3282)
1 parent ae16aab commit 018a078

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ local M = {
1414

1515
---@param windows integer[]
1616
local function close_windows(windows)
17-
-- Prevent from closing when the win count equals 1 or 2,
18-
-- where the win to remove could be the last opened.
19-
-- For details see #2503.
20-
if view.View.float.enable and #vim.api.nvim_list_wins() < 3 then
21-
return
17+
-- When floating, prevent closing the last non-floating window.
18+
-- For details see #2503, #3187.
19+
if view.View.float.enable then
20+
local non_float_count = 0
21+
for _, win in ipairs(vim.api.nvim_list_wins()) do
22+
if vim.api.nvim_win_get_config(win).relative == "" then
23+
non_float_count = non_float_count + 1
24+
end
25+
end
26+
if non_float_count <= 1 then
27+
return
28+
end
2229
end
2330

2431
for _, window in ipairs(windows) do

0 commit comments

Comments
 (0)