Skip to content

Commit 01f66ab

Browse files
committed
simplify collapse-all
1 parent 735381a commit 01f66ab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ local core = require("nvim-tree.core")
33
local lib = require("nvim-tree.lib")
44
local Iterator = require("nvim-tree.iterators.node-iterator")
55

6+
local DirectoryNode = require("nvim-tree.node.directory")
7+
68
local M = {}
79

810
---@return fun(path: string): boolean
@@ -36,8 +38,9 @@ function M.fn(keep_buffers)
3638
Iterator.builder(explorer.nodes)
3739
:hidden()
3840
:applier(function(n)
39-
if n.nodes ~= nil then
40-
n.open = keep_buffers == true and matches(n.absolute_path)
41+
local dir = n:as(DirectoryNode)
42+
if dir then
43+
dir.open = keep_buffers and matches(dir.absolute_path)
4144
end
4245
end)
4346
:recursor(function(n)

0 commit comments

Comments
 (0)