@@ -9,7 +9,10 @@ local M = {
9
9
}
10
10
11
11
local function close_windows (windows )
12
- if view .View .float .enable and # vim .api .nvim_list_wins () == 1 then
12
+ -- Prevent from closing when the win count equals 1 or 2,
13
+ -- where the win to remove could be the last opened.
14
+ -- For details see #2503.
15
+ if view .View .float .enable and # vim .api .nvim_list_wins () < 3 then
13
16
return
14
17
end
15
18
@@ -24,15 +27,15 @@ local function clear_buffer(absolute_path)
24
27
local bufs = vim .fn .getbufinfo { bufloaded = 1 , buflisted = 1 }
25
28
for _ , buf in pairs (bufs ) do
26
29
if buf .name == absolute_path then
30
+ local tree_winnr = vim .api .nvim_get_current_win ()
27
31
if buf .hidden == 0 and (# bufs > 1 or view .View .float .enable ) then
28
- local winnr = vim .api .nvim_get_current_win ()
29
32
vim .api .nvim_set_current_win (buf .windows [1 ])
30
33
vim .cmd " :bn"
31
- if not view .View .float .enable then
32
- vim .api .nvim_set_current_win (winnr )
33
- end
34
34
end
35
35
vim .api .nvim_buf_delete (buf .bufnr , { force = true })
36
+ if not view .View .float .quit_on_focus_loss then
37
+ vim .api .nvim_set_current_win (tree_winnr )
38
+ end
36
39
if M .config .actions .remove_file .close_window then
37
40
close_windows (buf .windows )
38
41
end
0 commit comments