Skip to content

Commit fb2e4f1

Browse files
committed
remove unloaded_bufnr checks as the view debouncer takes care of it
1 parent 3ab6dca commit fb2e4f1

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

lua/nvim-tree/buffers.lua

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ local M = {}
33
---@type table<string, boolean> record of which file is modified
44
M._modified = {}
55

6-
---@type number unloaded_bufnr for the duration of BufUnload
7-
M._unloaded_bufnr = nil
8-
96
---refresh M._modified
107
function M.reload_modified()
118
M._modified = {}
@@ -36,22 +33,11 @@ function M.is_modified(node)
3633
and (not node.open or M.config.modified.show_on_open_dirs)
3734
end
3835

39-
---A buffer exists for the node's absolute path and it's not in the middle of a BufUnload handler.
36+
---A buffer exists for the node's absolute path
4037
---@param node table
4138
---@return boolean
4239
function M.is_opened(node)
43-
return node and vim.fn.bufloaded(node.absolute_path) > 0 and vim.fn.bufnr(node.absolute_path) ~= M._unloaded_bufnr
44-
end
45-
46-
---Set the unloaded bufnr - at the start of the BufUnload handler.
47-
---@param bufnr number
48-
function M.set_unloaded_bufnr(bufnr)
49-
M._unloaded_bufnr = bufnr
50-
end
51-
52-
---Reset the unloaded bufnr - at the end of the BufUnload handler.
53-
function M.reset_unloaded_bufnr()
54-
M._unloaded_bufnr = nil
40+
return node and vim.fn.bufloaded(node.absolute_path) > 0
5541
end
5642

5743
---@param opts table

lua/nvim-tree/explorer/filters.lua

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ end
4747
---Check if the given path has no listed buffer
4848
---@param path string Absolute path
4949
---@param bufinfo table vim.fn.getbufinfo { buflisted = 1 }
50-
---@param unloaded_bufnr number optional bufnr recently unloaded via BufUnload event
5150
---@return boolean
52-
local function buf(path, bufinfo, unloaded_bufnr)
51+
local function buf(path, bufinfo)
5352
if not M.config.filter_no_buffer or type(bufinfo) ~= "table" then
5453
return false
5554
end
5655

5756
-- filter files with no open buffer and directories containing no open buffers
5857
for _, b in ipairs(bufinfo) do
59-
if b.name == path or b.name:find(path .. "/", 1, true) and b.bufnr ~= unloaded_bufnr then
58+
if b.name == path or b.name:find(path .. "/", 1, true) then
6059
return false
6160
end
6261
end
@@ -105,16 +104,13 @@ end
105104

106105
---Prepare arguments for should_filter. This is done prior to should_filter for efficiency reasons.
107106
---@param git_status table|nil optional results of git.load_project_status(...)
108-
---@param unloaded_bufnr number|nil optional bufnr recently unloaded via BufUnload event
109107
---@return table
110108
--- git_status: reference
111-
--- unloaded_bufnr: copy
112109
--- bufinfo: empty unless no_buffer set: vim.fn.getbufinfo { buflisted = 1 }
113110
--- bookmarks: absolute paths to boolean
114-
function M.prepare(git_status, unloaded_bufnr)
111+
function M.prepare(git_status)
115112
local status = {
116113
git_status = git_status or {},
117-
unloaded_bufnr = unloaded_bufnr,
118114
bufinfo = {},
119115
bookmarks = {},
120116
}
@@ -140,11 +136,7 @@ function M.should_filter(path, status)
140136
return false
141137
end
142138

143-
return git(path, status.git_status)
144-
or buf(path, status.bufinfo, status.unloaded_bufnr)
145-
or dotfile(path)
146-
or custom(path)
147-
or bookmark(path, status.bookmarks)
139+
return git(path, status.git_status) or buf(path, status.bufinfo) or dotfile(path) or custom(path) or bookmark(path, status.bookmarks)
148140
end
149141

150142
function M.setup(opts)

lua/nvim-tree/explorer/reload.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ end
6969

7070
---@param node Node
7171
---@param git_status table
72-
---@param unloaded_bufnr number|nil
73-
function M.reload(node, git_status, unloaded_bufnr)
72+
function M.reload(node, git_status)
7473
local cwd = node.link_to or node.absolute_path
7574
local handle = vim.loop.fs_scandir(cwd)
7675
if not handle then
@@ -79,7 +78,7 @@ function M.reload(node, git_status, unloaded_bufnr)
7978

8079
local profile = log.profile_start("reload %s", node.absolute_path)
8180

82-
local filter_status = filters.prepare(git_status, unloaded_bufnr)
81+
local filter_status = filters.prepare(git_status)
8382

8483
if node.group_next then
8584
node.nodes = { node.group_next }

0 commit comments

Comments
 (0)