parent
deb1f253f4
commit
1bdef08cfa
@ -21,9 +21,14 @@ local function populate_children(handle, cwd, node, status)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local nodes_by_path = utils.key_by(node.nodes, "absolute_path")
|
||||||
local abs = utils.path_join { cwd, name }
|
local abs = utils.path_join { cwd, name }
|
||||||
t = get_type_from(t, abs)
|
t = get_type_from(t, abs)
|
||||||
if not filters.should_ignore(abs) and not filters.should_ignore_git(abs, status.files) then
|
if
|
||||||
|
not filters.should_ignore(abs)
|
||||||
|
and not filters.should_ignore_git(abs, status.files)
|
||||||
|
and not nodes_by_path[abs]
|
||||||
|
then
|
||||||
if t == "directory" and uv.fs_access(abs, "R") then
|
if t == "directory" and uv.fs_access(abs, "R") then
|
||||||
table.insert(node.nodes, builders.folder(abs, name, status, node_ignored))
|
table.insert(node.nodes, builders.folder(abs, name, status, node_ignored))
|
||||||
elseif t == "file" then
|
elseif t == "file" then
|
||||||
|
|||||||
@ -9,14 +9,6 @@ local sorters = require "nvim-tree.explorer.sorters"
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function key_by(nodes, key)
|
|
||||||
local v = {}
|
|
||||||
for _, node in ipairs(nodes) do
|
|
||||||
v[node[key]] = node
|
|
||||||
end
|
|
||||||
return v
|
|
||||||
end
|
|
||||||
|
|
||||||
local function update_status(nodes_by_path, node_ignored, status)
|
local function update_status(nodes_by_path, node_ignored, status)
|
||||||
return function(node)
|
return function(node)
|
||||||
if nodes_by_path[node.absolute_path] then
|
if nodes_by_path[node.absolute_path] then
|
||||||
@ -46,7 +38,7 @@ function M.reload(node, status)
|
|||||||
local child_names = {}
|
local child_names = {}
|
||||||
|
|
||||||
local node_ignored = node.git_status == "!!"
|
local node_ignored = node.git_status == "!!"
|
||||||
local nodes_by_path = key_by(node.nodes, "absolute_path")
|
local nodes_by_path = utils.key_by(node.nodes, "absolute_path")
|
||||||
while true do
|
while true do
|
||||||
local name, t = uv.fs_scandir_next(handle)
|
local name, t = uv.fs_scandir_next(handle)
|
||||||
if not name then
|
if not name then
|
||||||
|
|||||||
@ -210,4 +210,12 @@ function M.format_bytes(bytes)
|
|||||||
return (units[pow] == nil) and (bytes .. "B") or (value .. units[pow])
|
return (units[pow] == nil) and (bytes .. "B") or (value .. units[pow])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.key_by(tbl, key)
|
||||||
|
local keyed = {}
|
||||||
|
for _, val in ipairs(tbl) do
|
||||||
|
keyed[val[key]] = val
|
||||||
|
end
|
||||||
|
return keyed
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user