File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,17 @@ local function setup_autocommands(opts)
236236 end ,
237237 })
238238 end
239+
240+ -- Handles event dispatch when tree is closed by `:q`
241+ create_nvim_tree_autocmd (" WinClosed" , {
242+ pattern = " *" ,
243+ --- @param ev vim.api.keyset.create_autocmd.callback_args
244+ callback = function (ev )
245+ if vim .api .nvim_get_option_value (" filetype" , { buf = ev .buf }) == " NvimTree" then
246+ require (" nvim-tree.events" )._dispatch_on_tree_close ()
247+ end
248+ end ,
249+ })
239250end
240251
241252local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
Original file line number Diff line number Diff line change 11local view = require (" nvim-tree.view" )
22local core = require (" nvim-tree.core" )
3- local events = require (" nvim-tree.events" )
43local notify = require (" nvim-tree.notify" )
54
65--- @class LibOpenOpts
@@ -131,7 +130,6 @@ function M.open(opts)
131130 open_view_and_draw ()
132131 end
133132 view .restore_tab_state ()
134- events ._dispatch_on_tree_open ()
135133end
136134
137135function M .setup (opts )
Original file line number Diff line number Diff line change @@ -255,7 +255,6 @@ local function close(tabpage)
255255 return
256256 end
257257 end
258- events ._dispatch_on_tree_close ()
259258 return
260259 end
261260 end
@@ -427,6 +426,7 @@ function M.open_in_win(opts)
427426 M .reposition_window ()
428427 M .resize ()
429428 end
429+ events ._dispatch_on_tree_open ()
430430end
431431
432432function M .abandon_current_window ()
You can’t perform that action at this time.
0 commit comments