chore(iterators): create Iterator module and migrate iterators to use it (#1392)
This commit is contained in:
@@ -3,6 +3,7 @@ local utils = require "nvim-tree.utils"
|
||||
local git_utils = require "nvim-tree.git.utils"
|
||||
local Runner = require "nvim-tree.git.runner"
|
||||
local Watcher = require("nvim-tree.watcher").Watcher
|
||||
local Iterator = require "nvim-tree.iterators.node-iterator"
|
||||
|
||||
local M = {
|
||||
config = {},
|
||||
@@ -84,21 +85,19 @@ local function reload_tree_at(project_root)
|
||||
local project_files = project.files and project.files or {}
|
||||
local project_dirs = project.dirs and project.dirs or {}
|
||||
|
||||
local function iterate(n)
|
||||
local parent_ignored = n.git_status == "!!"
|
||||
for _, node in pairs(n.nodes) do
|
||||
Iterator.builder(root_node.nodes)
|
||||
:hidden()
|
||||
:applier(function(node)
|
||||
local parent_ignored = node.parent.git_status == "!!"
|
||||
node.git_status = project_dirs[node.absolute_path] or project_files[node.absolute_path]
|
||||
if not node.git_status and parent_ignored then
|
||||
node.git_status = "!!"
|
||||
end
|
||||
|
||||
if node.nodes and #node.nodes > 0 then
|
||||
iterate(node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
iterate(root_node)
|
||||
end)
|
||||
:recursor(function(node)
|
||||
return node.nodes and #node.nodes > 0 and node.nodes
|
||||
end)
|
||||
:iterate()
|
||||
|
||||
require("nvim-tree.renderer").draw()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user