Skip to content

Commit 622a8d1

Browse files
committed
chore: resolve undefined-field
1 parent 009b2c9 commit 622a8d1

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

lua/nvim-tree/actions/tree/modifiers/collapse-all.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ function M.fn(keep_buffers)
4646
end
4747
end)
4848
:recursor(function(n)
49-
n = n and n:as(DirectoryNode)
50-
return n and (n.group_next and { n.group_next } or n.nodes)
49+
return n.group_next and { n.group_next } or n.nodes
5150
end)
5251
:iterate()
5352

lua/nvim-tree/actions/tree/modifiers/expand-all.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ local function gen_iterator()
6060
end
6161
end)
6262
:recursor(function(node)
63-
node = node and node:as(DirectoryNode)
64-
return expansion_count < M.MAX_FOLDER_DISCOVERY and node and (node.group_next and { node.group_next } or (node.open and node.nodes))
63+
return expansion_count < M.MAX_FOLDER_DISCOVERY and (node.group_next and { node.group_next } or (node.open and node.nodes))
6564
end)
6665
:iterate()
6766

lua/nvim-tree/explorer/live-filter.lua

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ local function reset_filter(self, node_)
3737
local dir_ = node_:as(DirectoryNode)
3838
if dir_ then
3939
dir_.hidden_stats = vim.tbl_deep_extend("force", dir_.hidden_stats or {}, { live_filter = 0, })
40-
41-
Iterator.builder(dir_.nodes)
42-
:hidden()
43-
:applier(function(node)
44-
node.hidden = false
45-
local dir = node:as(DirectoryNode)
46-
if dir then
47-
dir.hidden_stats = vim.tbl_deep_extend("force", dir.hidden_stats or {}, { live_filter = 0, })
48-
end
49-
end)
50-
:iterate()
5140
end
41+
42+
Iterator.builder(node_.nodes)
43+
:hidden()
44+
:applier(function(node)
45+
node.hidden = false
46+
local dir = node:as(DirectoryNode)
47+
if dir then
48+
dir.hidden_stats = vim.tbl_deep_extend("force", dir.hidden_stats or {}, { live_filter = 0, })
49+
end
50+
end)
51+
:iterate()
5252
end
5353

5454
local overlay_bufnr = 0

lua/nvim-tree/git/init.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,28 +204,26 @@ local function reload_tree_at(toplevel)
204204
end
205205

206206
log.line("watcher", "git event executing '%s'", toplevel)
207-
local base = utils.get_node_from_path(toplevel)
208-
base = base and base:as(DirectoryNode)
209-
if not base then
207+
local root_node = utils.get_node_from_path(toplevel)
208+
if not root_node then
210209
return
211210
end
212211

213212
M.reload_project(toplevel, nil, function()
214213
local git_status = M.get_project(toplevel)
215214

216-
Iterator.builder(base.nodes)
215+
Iterator.builder(root_node.nodes)
217216
:hidden()
218217
:applier(function(node)
219218
local parent_ignored = node.parent and node.parent:is_git_ignored() or false
220219
node:update_git_status(parent_ignored, git_status)
221220
end)
222221
:recursor(function(node)
223-
local dir = node:as(DirectoryNode)
224-
return dir and #dir.nodes > 0 and dir.nodes
222+
return node.nodes and #node.nodes > 0 and node.nodes
225223
end)
226224
:iterate()
227225

228-
base.explorer.renderer:draw()
226+
root_node.explorer.renderer:draw()
229227
end)
230228
end
231229

0 commit comments

Comments
 (0)