vim: nvim-tree: revert: track bufnr via buffer-update channel
This commit is contained in:
parent
0a437b31be
commit
6347a2c173
@ -105,7 +105,10 @@ function Explorer:create_autocmds()
|
||||
vim.api.nvim_create_autocmd("WinLeave", {
|
||||
group = self.augroup_id,
|
||||
pattern = "NvimTree_*",
|
||||
callback = function()
|
||||
callback = function(data)
|
||||
if self.opts.experimental.multi_instance then
|
||||
log.line("dev", "WinLeave %s", vim.inspect(data, { newline = "" }))
|
||||
end
|
||||
if utils.is_nvim_tree_buf(0) then
|
||||
self.view:close(nil, "WinLeave")
|
||||
end
|
||||
@ -169,14 +172,17 @@ function Explorer:create_autocmds()
|
||||
vim.api.nvim_create_autocmd("BufWipeout", {
|
||||
group = self.augroup_id,
|
||||
pattern = "NvimTree_*",
|
||||
callback = function()
|
||||
callback = function(data)
|
||||
if self.opts.experimental.multi_instance then
|
||||
log.line("dev", "BufWipeout %s", vim.inspect(data, { newline = "" }))
|
||||
end
|
||||
if not utils.is_nvim_tree_buf(0) then
|
||||
return
|
||||
end
|
||||
if self.opts.actions.open_file.eject then
|
||||
self.view:prevent_buffer_override()
|
||||
else
|
||||
self.view:abandon_current_window("BufWipeout")
|
||||
self.view:abandon_current_window()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@ -131,16 +131,7 @@ function View:create_buffer(bufnr)
|
||||
globals.BUFNR_PER_TAB[tab] = bufnr or vim.api.nvim_create_buf(false, false)
|
||||
|
||||
if self.explorer.opts.experimental.multi_instance then
|
||||
local tabid = tab
|
||||
self.bufnr_by_tab[tabid] = globals.BUFNR_PER_TAB[tabid]
|
||||
|
||||
log.line("dev", "buffer channel attaching t%d b%d", tabid, self.bufnr_by_tab[tabid])
|
||||
vim.api.nvim_buf_attach(self.bufnr_by_tab[tabid], false, {
|
||||
on_detach = function(op, bnr)
|
||||
log.line("dev", "buffer channel %s t%d b%d", op, tabid, bnr)
|
||||
self.bufnr_by_tab[tabid] = nil
|
||||
end,
|
||||
})
|
||||
self.bufnr_by_tab[tab] = globals.BUFNR_PER_TAB[tab]
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_set_name(self:get_bufnr("View:create_buffer1"), "NvimTree_" .. tab)
|
||||
@ -508,18 +499,18 @@ function View:open_in_win(opts)
|
||||
events._dispatch_on_tree_open()
|
||||
end
|
||||
|
||||
---@param callsite string
|
||||
function View:abandon_current_window(callsite)
|
||||
function View:abandon_current_window()
|
||||
local tab = vim.api.nvim_get_current_tabpage()
|
||||
|
||||
if self.explorer.opts.experimental.multi_instance then
|
||||
log.line("dev", "View:abandon_current_window(%-20.20s) t%d w%s b%s member b%s %s",
|
||||
callsite,
|
||||
log.line("dev", "View:abandon_current_window() t%d w%s b%s member b%s %s",
|
||||
tab,
|
||||
globals.TABPAGES[tab] and globals.TABPAGES[tab].winnr or nil,
|
||||
globals.BUFNR_PER_TAB[tab],
|
||||
self.bufnr_by_tab[tab],
|
||||
(globals.BUFNR_PER_TAB[tab] == self.bufnr_by_tab[tab]) and "" or "MISMATCH")
|
||||
|
||||
self.bufnr_by_tab[tab] = nil
|
||||
end
|
||||
|
||||
-- TODO multi-instance kill the buffer instead of retaining
|
||||
|
||||
Loading…
Reference in New Issue
Block a user