Fix empty dir icons updating incorrectly

This commit is contained in:
Cooper b. Anderson
2021-02-18 06:47:24 -05:00
committed by Kiyan
parent 84aa8d7ba7
commit 6647f96739
3 changed files with 5 additions and 6 deletions

View File

@@ -92,6 +92,7 @@ end
function M.unroll_dir(node)
node.open = not node.open
if node.children_initial then node.children_initial = false end
if #node.entries > 0 then
renderer.draw(M.Tree, true)
else

View File

@@ -15,9 +15,8 @@ local path_to_matching_str = require'lib.utils'.path_to_matching_str
local function dir_new(cwd, name)
local absolute_path = cwd..'/'..name
local stat = luv.fs_stat(absolute_path)
local handle = luv.fs_opendir(absolute_path, nil, 1)
local child = luv.fs_readdir(handle)
luv.fs_closedir(handle)
local handle = luv.fs_scandir(absolute_path)
local has_children = luv.fs_scandir_next(handle) ~= nil
return {
name = name,
absolute_path = absolute_path,
@@ -26,7 +25,7 @@ local function dir_new(cwd, name)
match_name = path_to_matching_str(name),
match_path = path_to_matching_str(absolute_path),
open = false,
has_children = child ~= nil,
children_initial = has_children,
entries = {}
}
end

View File

@@ -238,8 +238,7 @@ local function update_draw_data(tree, depth, markers)
local git_hl = get_git_hl(node)
if node.entries then
local icon = get_folder_icon(node.open, node.link_to ~= nil, #node.entries ~= 0 or node.has_children)
if node.has_children then node.has_children = nil end
local icon = get_folder_icon(node.open, node.link_to ~= nil, #node.entries ~= 0 or node.children_initial)
local git_icon = get_git_icons(node, index, offset, #icon+1) or ""
-- INFO: this is mandatory in order to keep gui attributes (bold/italics)
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'NvimTreeFolderName')