fix: do not group empty at root

This commit is contained in:
kiyan 2022-02-07 21:16:59 +01:00
parent 1ab7812c62
commit e42a4337d0
2 changed files with 6 additions and 4 deletions

View file

@ -36,9 +36,10 @@ function M.explore(node, cwd, status)
end
end
if vim.g.nvim_tree_group_empty == 1 then
local is_root = node.cwd ~= nil
if vim.g.nvim_tree_group_empty == 1 and not is_root and #(node.nodes) == 1 then
local child_node = node.nodes[1]
if #(node.nodes) == 1 and child_node.nodes and uv.fs_access(child_node.absolute_path, 'R') then
if child_node.nodes and uv.fs_access(child_node.absolute_path, 'R') then
node.group_next = child_node
local ns = M.explore(child_node, child_node.absolute_path, status)
node.nodes = ns or {}

View file

@ -59,9 +59,10 @@ function M.reload(node, cwd, status)
node.nodes
)
if vim.g.nvim_tree_group_empty == 1 then
local is_root = node.cwd ~= nil
if vim.g.nvim_tree_group_empty == 1 and not is_root and #(node.nodes) == 1 then
local child_node = node.nodes[1]
if #(node.nodes) == 1 and child_node.nodes and uv.fs_access(child_node.absolute_path, 'R') then
if child_node.nodes and uv.fs_access(child_node.absolute_path, 'R') then
node.group_next = child_node
local ns = M.reload(child_node, child_node.absolute_path, status)
node.nodes = ns or {}