Skip to content

Commit 5dc93f3

Browse files
committed
Revert "feat(#2826): remove globals.BUFNR_BY_TABID"
This reverts commit 2651f9b.
1 parent 2651f9b commit 5dc93f3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lua/nvim-tree/explorer/view.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function View:log_event(data, bufnr)
8787
vim.api.nvim_get_current_tabpage() = %s\
8888
vim.api.nvim_get_current_win() = %s\
8989
self.bufnr_by_tabid = %s\
90+
globals.BUFNR_BY_TABID = %s\
9091
globals.WINID_BY_TABID = %s\
9192
vim.fn.win_findbuf(bufnr) = %s\
9293
data = %s\
@@ -96,6 +97,7 @@ function View:log_event(data, bufnr)
9697
vim.api.nvim_get_current_tabpage(),
9798
vim.api.nvim_get_current_win(),
9899
vim.inspect(self.bufnr_by_tabid, { newline = "" }),
100+
vim.inspect(globals.BUFNR_BY_TABID, { newline = "" }),
99101
vim.inspect(globals.WINID_BY_TABID, { newline = "" }),
100102
vim.inspect(vim.fn.win_findbuf(bufnr), { newline = "" }),
101103
vim.inspect(data, { newline = "" }),
@@ -177,7 +179,7 @@ end
177179
---@param bufnr integer
178180
---@return boolean
179181
function View:matches_bufnr(bufnr)
180-
for _, b in pairs(self.bufnr_by_tabid) do
182+
for _, b in pairs(globals.BUFNR_BY_TABID) do
181183
if b == bufnr then
182184
return true
183185
end
@@ -206,6 +208,8 @@ function View:create_buffer(bufnr)
206208

207209
self.bufnr_by_tabid[tabid] = bufnr
208210

211+
globals.BUFNR_BY_TABID[tabid] = bufnr
212+
209213
vim.api.nvim_buf_set_name(bufnr, "NvimTree_" .. tabid)
210214

211215
for _, option in ipairs(BUFFER_OPTIONS) do
@@ -540,14 +544,14 @@ end
540544
function View:abandon_current_window()
541545
local tab = vim.api.nvim_get_current_tabpage()
542546

543-
self.bufnr_by_tabid[tab] = nil
547+
globals.BUFNR_BY_TABID[tab] = nil
544548

545549
globals.WINID_BY_TABID[tab] = nil
546550
end
547551

548552
function View:abandon_all_windows()
549553
for tab, _ in pairs(vim.api.nvim_list_tabpages()) do
550-
self.bufnr_by_tabid[tab] = nil
554+
globals.BUFNR_BY_TABID[tab] = nil
551555
globals.WINID_BY_TABID[tab] = nil
552556
end
553557
end
@@ -624,7 +628,7 @@ end
624628
---@param tabid number|nil (optional) the number of the chosen tabpage. Defaults to current tabpage.
625629
---@return integer? winid
626630
function View:winid(tabid)
627-
local bufnr = self.bufnr_by_tabid[tabid]
631+
local bufnr = globals.BUFNR_BY_TABID[tabid]
628632

629633
if bufnr then
630634
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(tabid or 0)) do
@@ -649,7 +653,7 @@ end
649653
function View:get_bufnr()
650654
local tab = vim.api.nvim_get_current_tabpage()
651655

652-
return self.bufnr_by_tabid[tab]
656+
return globals.BUFNR_BY_TABID[tab]
653657
end
654658

655659
function View:prevent_buffer_override()

lua/nvim-tree/globals.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
local M = {
44
-- from View
55
WINID_BY_TABID = {},
6+
BUFNR_BY_TABID = {},
67
CURSORS = {},
78
}
89

0 commit comments

Comments
 (0)