Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert window close buffer cleanup code #1433

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 14 additions & 13 deletions lua/neo-tree/ui/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ M.close = function(state, focus_prior_window)
end
vim.api.nvim_win_set_buf(state.winid, new_buf)
else
local args = {
position = state.current_position,
source = state.name,
winid = state.winid,
tabnr = tabid_to_tabnr(state.tabid), -- for compatibility
tabid = state.tabid,
}
events.fire_event(events.NEO_TREE_WINDOW_BEFORE_CLOSE, args)
local win_list = vim.api.nvim_tabpage_list_wins(0)
if focus_prior_window and #win_list > 1 then
local args = {
position = state.current_position,
source = state.name,
winid = state.winid,
tabnr = tabid_to_tabnr(state.tabid), -- for compatibility
tabid = state.tabid,
}
-- focus the prior used window if we are closing the currently focused window
local current_winid = vim.api.nvim_get_current_win()
if current_winid == state.winid then
Expand All @@ -163,14 +163,15 @@ M.close = function(state, focus_prior_window)
end
state.winid = nil
end
if window_existed then
local bufnr = utils.get_value(state, "bufnr", 0, true)
local bufnr = utils.get_value(state, "bufnr", 0, true)
if bufnr > 0 and vim.api.nvim_buf_is_valid(bufnr) then
state.bufnr = nil
vim.schedule(function()
if bufnr > 0 and vim.api.nvim_buf_is_valid(bufnr) then
local success, err = pcall(vim.api.nvim_buf_delete, bufnr, { force = true })
if not success and err and err:match("E523") then
vim.schedule_wrap(function()
vim.api.nvim_buf_delete(bufnr, { force = true })
end
end)
end)()
end
end
return window_existed
end
Expand Down