Skip to content

Commit 2651f9b

Browse files
committed
feat(#2826): remove globals.BUFNR_BY_TABID
1 parent 498641a commit 2651f9b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lua/nvim-tree/explorer/view.lua

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ 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\
9190
globals.WINID_BY_TABID = %s\
9291
vim.fn.win_findbuf(bufnr) = %s\
9392
data = %s\
@@ -97,7 +96,6 @@ function View:log_event(data, bufnr)
9796
vim.api.nvim_get_current_tabpage(),
9897
vim.api.nvim_get_current_win(),
9998
vim.inspect(self.bufnr_by_tabid, { newline = "" }),
100-
vim.inspect(globals.BUFNR_BY_TABID, { newline = "" }),
10199
vim.inspect(globals.WINID_BY_TABID, { newline = "" }),
102100
vim.inspect(vim.fn.win_findbuf(bufnr), { newline = "" }),
103101
vim.inspect(data, { newline = "" }),
@@ -179,7 +177,7 @@ end
179177
---@param bufnr integer
180178
---@return boolean
181179
function View:matches_bufnr(bufnr)
182-
for _, b in pairs(globals.BUFNR_BY_TABID) do
180+
for _, b in pairs(self.bufnr_by_tabid) do
183181
if b == bufnr then
184182
return true
185183
end
@@ -208,8 +206,6 @@ function View:create_buffer(bufnr)
208206

209207
self.bufnr_by_tabid[tabid] = bufnr
210208

211-
globals.BUFNR_BY_TABID[tabid] = bufnr
212-
213209
vim.api.nvim_buf_set_name(bufnr, "NvimTree_" .. tabid)
214210

215211
for _, option in ipairs(BUFFER_OPTIONS) do
@@ -544,14 +540,14 @@ end
544540
function View:abandon_current_window()
545541
local tab = vim.api.nvim_get_current_tabpage()
546542

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

549545
globals.WINID_BY_TABID[tab] = nil
550546
end
551547

552548
function View:abandon_all_windows()
553549
for tab, _ in pairs(vim.api.nvim_list_tabpages()) do
554-
globals.BUFNR_BY_TABID[tab] = nil
550+
self.bufnr_by_tabid[tab] = nil
555551
globals.WINID_BY_TABID[tab] = nil
556552
end
557553
end
@@ -628,7 +624,7 @@ end
628624
---@param tabid number|nil (optional) the number of the chosen tabpage. Defaults to current tabpage.
629625
---@return integer? winid
630626
function View:winid(tabid)
631-
local bufnr = globals.BUFNR_BY_TABID[tabid]
627+
local bufnr = self.bufnr_by_tabid[tabid]
632628

633629
if bufnr then
634630
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(tabid or 0)) do
@@ -653,7 +649,7 @@ end
653649
function View:get_bufnr()
654650
local tab = vim.api.nvim_get_current_tabpage()
655651

656-
return globals.BUFNR_BY_TABID[tab]
652+
return self.bufnr_by_tabid[tab]
657653
end
658654

659655
function View:prevent_buffer_override()

lua/nvim-tree/globals.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
local M = {
44
-- from View
55
WINID_BY_TABID = {},
6-
BUFNR_BY_TABID = {},
76
CURSORS = {},
87
}
98

0 commit comments

Comments
 (0)