Skip to content

Commit 641f125

Browse files
committed
Fix warnings
1 parent c1948cb commit 641f125

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ end
4848
---@return boolean
4949
local function should_expand(expansion_count, node, should_descend)
5050
local dir = node:as(DirectoryNode)
51-
return dir and not dir.open and should_descend(expansion_count, node)
51+
if not dir then
52+
return false
53+
end
54+
55+
return not dir.open and should_descend(expansion_count, node)
5256
end
5357

5458

5559
---@param should_descend fun(expansion_count: integer, node: Node): boolean
60+
---@return fun(node): any
5661
local function gen_iterator(should_descend)
5762
local expansion_count = 0
5863

lua/nvim-tree/api.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ Api.tree.collapse_all = wrap(actions.tree.modifiers.collapse.all)
232232
Api.tree.expand_all = wrap_node(actions.tree.modifiers.expand.all)
233233

234234
Api.tree.toggle_descend_until = wrap_node(function(node, descend_until)
235-
if node.open then
236-
local dir = node:as(DirectoryNode)
237-
dir:expand_or_collapse("edit")
238-
else
239-
if node.nodes then
240-
actions.tree.modifiers.expand.all(node, { descend_until = descend_until })
235+
local dir = node:as(DirectoryNode)
236+
if dir then
237+
if node.open then
238+
dir:expand_or_collapse(nil)
241239
else
242-
edit("edit", node)
240+
actions.tree.modifiers.expand.all(node, { descend_until = descend_until })
243241
end
242+
else
243+
edit("edit", node)
244244
end
245245
end)
246246

0 commit comments

Comments
 (0)