Skip to content

Commit bbeabac

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

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

lua/nvim-tree.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ local function setup_autocommands(opts)
231231
-- update opened file buffers
232232
if (filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
233233
utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function()
234-
buffers.set_unloaded_bufnr(data.buf)
235234
reloaders.reload_explorer()
236-
buffers.reset_unloaded_bufnr()
237235
end)
238236
end
239237
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
@@ -44,16 +44,15 @@ end
4444
---Check if the given path has no listed buffer
4545
---@param path string Absolute path
4646
---@param bufinfo table vim.fn.getbufinfo { buflisted = 1 }
47-
---@param unloaded_bufnr number optional bufnr recently unloaded via BufUnload event
4847
---@return boolean
49-
local function buf(path, bufinfo, unloaded_bufnr)
48+
local function buf(path, bufinfo)
5049
if not M.config.filter_no_buffer or type(bufinfo) ~= "table" then
5150
return false
5251
end
5352

5453
-- filter files with no open buffer and directories containing no open buffers
5554
for _, b in ipairs(bufinfo) do
56-
if b.name == path or b.name:find(path .. "/", 1, true) and b.bufnr ~= unloaded_bufnr then
55+
if b.name == path or b.name:find(path .. "/", 1, true) then
5756
return false
5857
end
5958
end
@@ -92,15 +91,12 @@ end
9291

9392
---Prepare arguments for should_filter. This is done prior to should_filter for efficiency reasons.
9493
---@param git_status table|nil optional results of git.load_project_status(...)
95-
---@param unloaded_bufnr number|nil optional bufnr recently unloaded via BufUnload event
9694
---@return table
9795
--- git_status: reference
98-
--- unloaded_bufnr: copy
9996
--- bufinfo: empty unless no_buffer set: vim.fn.getbufinfo { buflisted = 1 }
100-
function M.prepare(git_status, unloaded_bufnr)
97+
function M.prepare(git_status)
10198
local status = {
10299
git_status = git_status or {},
103-
unloaded_bufnr = unloaded_bufnr,
104100
bufinfo = {},
105101
}
106102

@@ -121,7 +117,7 @@ function M.should_filter(path, status)
121117
return false
122118
end
123119

124-
return git(path, status.git_status) or buf(path, status.bufinfo, status.unloaded_bufnr) or dotfile(path) or custom(path)
120+
return git(path, status.git_status) or buf(path, status.bufinfo) or dotfile(path) or custom(path)
125121
end
126122

127123
function M.setup(opts)

lua/nvim-tree/explorer/reload.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ local function update_parent_statuses(node, project, root)
5858
end
5959
end
6060

61-
function M.reload(node, git_status, unloaded_bufnr)
61+
function M.reload(node, git_status)
6262
local cwd = node.link_to or node.absolute_path
6363
local handle = vim.loop.fs_scandir(cwd)
6464
if not handle then
@@ -67,7 +67,7 @@ function M.reload(node, git_status, unloaded_bufnr)
6767

6868
local profile = log.profile_start("reload %s", node.absolute_path)
6969

70-
local filter_status = filters.prepare(git_status, unloaded_bufnr)
70+
local filter_status = filters.prepare(git_status)
7171

7272
if node.group_next then
7373
node.nodes = { node.group_next }

0 commit comments

Comments
 (0)