@@ -85,19 +85,24 @@ end
|
|||||||
-- get the node from the tree that matches the predicate
|
-- get the node from the tree that matches the predicate
|
||||||
-- @param nodes list of node
|
-- @param nodes list of node
|
||||||
-- @param fn function(node): boolean
|
-- @param fn function(node): boolean
|
||||||
function M.find_node(nodes, fn)
|
function M.find_node(_nodes, _fn)
|
||||||
local i = 1
|
local function iter(nodes, fn)
|
||||||
for _, node in ipairs(nodes) do
|
local i = 1
|
||||||
if fn(node) then return node, i end
|
for _, node in ipairs(nodes) do
|
||||||
if node.open and #node.entries > 0 then
|
if fn(node) then return node, i end
|
||||||
local n, idx = M.find_node(node.entries, fn)
|
if node.open and #node.entries > 0 then
|
||||||
i = i + idx
|
local n, idx = iter(node.entries, fn)
|
||||||
if n then return n, i end
|
i = i + idx
|
||||||
else
|
if n then return n, i end
|
||||||
i = i + 1
|
else
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
return nil, i
|
||||||
end
|
end
|
||||||
return nil, i
|
local node, i = iter(_nodes, _fn)
|
||||||
|
i = require'nvim-tree.view'.View.hide_root_folder and i - 1 or i
|
||||||
|
return node, i
|
||||||
end
|
end
|
||||||
|
|
||||||
---Create a shallow copy of a portion of a list.
|
---Create a shallow copy of a portion of a list.
|
||||||
|
|||||||
Reference in New Issue
Block a user