Skip to content

Commit ab7742b

Browse files
committed
remove unloaded_bufnr checks as the view debouncer takes care of it
1 parent fd3fa84 commit ab7742b

File tree

4 files changed

+8
-29
lines changed

4 files changed

+8
-29
lines changed

lua/nvim-tree.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ local function setup_autocommands(opts)
213213
-- update opened file buffers
214214
if (filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
215215
utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function()
216-
buffers.set_unloaded_bufnr(data.buf)
217216
reloaders.reload_explorer()
218-
buffers.reset_unloaded_bufnr()
219217
end)
220218
end
221219
end,

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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ end
4646
---Check if the given path has no listed buffer
4747
---@param path string Absolute path
4848
---@param bufinfo table vim.fn.getbufinfo { buflisted = 1 }
49-
---@param unloaded_bufnr number optional bufnr recently unloaded via BufUnload event
5049
---@return boolean
51-
local function buf(path, bufinfo, unloaded_bufnr)
50+
local function buf(path, bufinfo)
5251
if not M.config.filter_no_buffer or type(bufinfo) ~= "table" then
5352
return false
5453
end
5554

5655
-- filter files with no open buffer and directories containing no open buffers
5756
for _, b in ipairs(bufinfo) do
58-
if b.name == path or b.name:find(path .. "/", 1, true) and b.bufnr ~= unloaded_bufnr then
57+
if b.name == path or b.name:find(path .. "/", 1, true) then
5958
return false
6059
end
6160
end
@@ -98,15 +97,12 @@ end
9897

9998
---Prepare arguments for should_filter. This is done prior to should_filter for efficiency reasons.
10099
---@param git_status table|nil optional results of git.load_project_status(...)
101-
---@param unloaded_bufnr number|nil optional bufnr recently unloaded via BufUnload event
102100
---@return table
103101
--- git_status: reference
104-
--- unloaded_bufnr: copy
105102
--- bufinfo: empty unless no_buffer set: vim.fn.getbufinfo { buflisted = 1 }
106-
function M.prepare(git_status, unloaded_bufnr)
103+
function M.prepare(git_status)
107104
local status = {
108105
git_status = git_status or {},
109-
unloaded_bufnr = unloaded_bufnr,
110106
bufinfo = {},
111107
}
112108

@@ -127,7 +123,7 @@ function M.should_filter(path, status)
127123
return false
128124
end
129125

130-
return git(path, status.git_status) or buf(path, status.bufinfo, status.unloaded_bufnr) or dotfile(path) or custom(path)
126+
return git(path, status.git_status) or buf(path, status.bufinfo) or dotfile(path) or custom(path)
131127
end
132128

133129
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)