Skip to content

Commit 79f631b

Browse files
feat(view): add float.quit_on_focus_loss, float respects actions.open_file.quit_on_open (#1621)
1 parent be2b4f5 commit 79f631b

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

doc/nvim-tree-lua.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,13 @@ Window / buffer setup.
702702
Configuration options for floating window
703703

704704
*nvim-tree.view.float.enable*
705-
Display nvim-tree window as float (enforces |nvim-tree.actions.open_file.quit_on_open| if set).
705+
Display nvim-tree window as float (enforces if set).
706706
Type: `boolean`, Default: `false`
707707

708+
*nvim-tree.view.float.quit_on_focus_loss
709+
When in floating mode, autoclose the popup when the popup loses the focus.
710+
Type: `boolean`, Default: `true`
711+
708712
*nvim-tree.view.float.open_win_config*
709713
Floating window config. See |nvim_open_win| for more details.
710714
Type: `table` or `function` that returns a table, Default:

lua/nvim-tree.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ local function setup_autocommands(opts)
412412
})
413413
end
414414

415-
if opts.view.float.enable then
415+
if opts.view.float.enable and opts.view.float.quit_on_focus_loss then
416416
create_nvim_tree_autocmd("WinLeave", { pattern = "NvimTree_*", callback = view.close })
417417
end
418418
end
@@ -457,6 +457,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
457457
},
458458
float = {
459459
enable = false,
460+
quit_on_focus_loss = true,
460461
open_win_config = {
461462
relative = "editor",
462463
border = "rounded",

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function M.fn(mode, filename)
267267
end
268268

269269
function M.setup(opts)
270-
M.quit_on_open = opts.actions.open_file.quit_on_open or opts.view.float.enable
270+
M.quit_on_open = opts.actions.open_file.quit_on_open
271271
M.resize_window = opts.actions.open_file.resize_window
272272
if opts.actions.open_file.window_picker.chars then
273273
opts.actions.open_file.window_picker.chars = tostring(opts.actions.open_file.window_picker.chars):upper()

lua/nvim-tree/live-filter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local overlay_bufnr = nil
2525
local overlay_winnr = nil
2626

2727
local function remove_overlay()
28-
if view.View.float.enable then
28+
if view.View.float.enable and view.View.float.quit_on_focus_loss then
2929
-- return to normal nvim-tree float behaviour when filter window is closed
3030
a.nvim_create_autocmd("WinLeave", {
3131
pattern = "NvimTree_*",

0 commit comments

Comments
 (0)