Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ local function setup_autocommands(opts)
end,
})
end

-- Handles event dispatch when tree is closed by `:q`
create_nvim_tree_autocmd("WinClosed", {
pattern = "*",
---@param ev vim.api.keyset.create_autocmd.callback_args
callback = function(ev)
if vim.api.nvim_get_option_value("filetype", { buf = ev.buf }) == "NvimTree" then
require("nvim-tree.events")._dispatch_on_tree_close()
end
end,
})
end

local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
Expand Down
2 changes: 0 additions & 2 deletions lua/nvim-tree/lib.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local view = require("nvim-tree.view")
local core = require("nvim-tree.core")
local events = require("nvim-tree.events")
local notify = require("nvim-tree.notify")

---@class LibOpenOpts
Expand Down Expand Up @@ -130,7 +129,6 @@ function M.open(opts)
open_view_and_draw()
end
view.restore_tab_state()
events._dispatch_on_tree_open()
end

function M.setup(opts)
Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ local function close(tabpage)
return
end
end
events._dispatch_on_tree_close()
return
end
end
Expand Down Expand Up @@ -425,6 +424,7 @@ function M.open_in_win(opts)
M.reposition_window()
M.resize()
end
events._dispatch_on_tree_open()
end

function M.abandon_current_window()
Expand Down
Loading