Skip to content

Commit 635bbf0

Browse files
committed
chore: remove TreePreClose event and update dispatch of TreePreOpen
1 parent a68a114 commit 635bbf0

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed

doc/nvim-tree-lua.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -2781,13 +2781,9 @@ e.g. handler for node renamed: >lua
27812781
Invoked after the NvimTree is opened.
27822782
• Note: Handler takes no parameter.
27832783

2784-
- Event.TreePreClose
2785-
Invoked before the window and buffer for NvimTree are closed.
2786-
Before |Event.TreeClose| event.
2787-
• Note: Handler takes no parameter.
2788-
27892784
- Event.TreeClose
2790-
Invoked after the NvimTree is closed.
2785+
Invoked after the NvimTree is closed, but before the window is
2786+
closed. Dispatched on |WinClosed| event for NvimTree window.
27912787
• Note: Handler takes no parameter.
27922788

27932789
- Event.Resize - When NvimTree is resized.

lua/nvim-tree/events.lua

-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ M.Event = {
1010
NodeRenamed = "NodeRenamed",
1111
TreePreOpen = "TreePreOpen",
1212
TreeOpen = "TreeOpen",
13-
TreePreClose = "TreePreClose",
1413
TreeClose = "TreeClose",
1514
WillCreateFile = "WillCreateFile",
1615
FileCreated = "FileCreated",
@@ -103,11 +102,6 @@ function M._dispatch_on_tree_open()
103102
dispatch(M.Event.TreeOpen, nil)
104103
end
105104

106-
--@private
107-
function M._dispatch_on_tree_pre_close()
108-
dispatch(M.Event.TreePreClose, nil)
109-
end
110-
111105
--@private
112106
function M._dispatch_on_tree_close()
113107
dispatch(M.Event.TreeClose, nil)

lua/nvim-tree/lib.lua

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ function M.open(opts)
109109

110110
local explorer = core.get_explorer()
111111

112-
events._dispatch_on_tree_pre_open()
113112
if should_hijack_current_buf() then
114113
view.close_this_tab_only()
115114
view.open_in_win()

lua/nvim-tree/view.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ local function close(tabpage)
238238
return
239239
end
240240
save_tab_state(tabpage)
241-
events._dispatch_on_tree_pre_close()
242241
switch_buf_if_last_buf()
243242
local tree_win = M.get_winnr(tabpage)
244243
local current_win = vim.api.nvim_get_current_win()
@@ -415,6 +414,7 @@ end
415414
---@param opts OpenInWinOpts|nil
416415
function M.open_in_win(opts)
417416
opts = opts or { hijack_current_buf = true, resize = true }
417+
events._dispatch_on_tree_pre_open()
418418
if opts.winid and vim.api.nvim_win_is_valid(opts.winid) then
419419
vim.api.nvim_set_current_win(opts.winid)
420420
end

0 commit comments

Comments
 (0)