Skip to content

Commit f922d01

Browse files
authored
Merge branch 'master' into refactor/3255-wire-actions-directly-to-functions
2 parents fe21338 + c988e28 commit f922d01

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
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

lua/nvim-tree/view.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,9 @@ local function grow()
319319
end
320320

321321
local final_width = M.View.initial_width
322-
local max_width = math.huge
323-
if M.View.max_width ~= -1 then
324-
max_width = get_width(M.View.max_width)
322+
local max_width = get_width(M.View.max_width)
323+
if max_width == -1 then
324+
max_width = math.huge
325325
end
326326

327327
local ns_id = vim.api.nvim_get_namespaces()["NvimTreeExtmarks"]

0 commit comments

Comments
 (0)