* fix(#2301): reloader handles grouped * fix(#2301): explore uses correct git project for grouped * fix(#2301): update parent status correctly across repositories * fix(#2301): missing require
This commit is contained in:
committed by
GitHub
parent
dea82ae207
commit
4e36850811
@@ -4,18 +4,22 @@ local renderer = require "nvim-tree.renderer"
|
|||||||
local explorer_module = require "nvim-tree.explorer"
|
local explorer_module = require "nvim-tree.explorer"
|
||||||
local core = require "nvim-tree.core"
|
local core = require "nvim-tree.core"
|
||||||
local explorer_node = require "nvim-tree.explorer.node"
|
local explorer_node = require "nvim-tree.explorer.node"
|
||||||
|
local Iterator = require "nvim-tree.iterators.node-iterator"
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function refresh_nodes(node, projects, unloaded_bufnr)
|
local function refresh_nodes(node, projects, unloaded_bufnr)
|
||||||
local cwd = node.cwd or node.link_to or node.absolute_path
|
Iterator.builder({ node })
|
||||||
local project_root = git.get_project_root(cwd)
|
:applier(function(n)
|
||||||
explorer_module.reload(node, projects[project_root] or {}, unloaded_bufnr)
|
if n.open and n.nodes then
|
||||||
for _, _node in ipairs(node.nodes) do
|
local project_root = git.get_project_root(n.cwd or n.link_to or n.absolute_path)
|
||||||
if _node.nodes and _node.open then
|
explorer_module.reload(n, projects[project_root] or {}, unloaded_bufnr)
|
||||||
refresh_nodes(_node, projects, unloaded_bufnr)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
|
:recursor(function(n)
|
||||||
|
return n.group_next and { n.group_next } or (n.open and n.nodes)
|
||||||
|
end)
|
||||||
|
:iterate()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.reload_node_status(parent_node, projects)
|
function M.reload_node_status(parent_node, projects)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local utils = require "nvim-tree.utils"
|
local utils = require "nvim-tree.utils"
|
||||||
local builders = require "nvim-tree.explorer.node-builders"
|
local builders = require "nvim-tree.explorer.node-builders"
|
||||||
local explorer_node = require "nvim-tree.explorer.node"
|
local explorer_node = require "nvim-tree.explorer.node"
|
||||||
|
local git = require "nvim-tree.git"
|
||||||
local sorters = require "nvim-tree.explorer.sorters"
|
local sorters = require "nvim-tree.explorer.sorters"
|
||||||
local filters = require "nvim-tree.explorer.filters"
|
local filters = require "nvim-tree.explorer.filters"
|
||||||
local live_filter = require "nvim-tree.live-filter"
|
local live_filter = require "nvim-tree.live-filter"
|
||||||
@@ -70,8 +71,10 @@ function M.explore(node, status)
|
|||||||
local is_root = not node.parent
|
local is_root = not node.parent
|
||||||
local child_folder_only = explorer_node.has_one_child_folder(node) and node.nodes[1]
|
local child_folder_only = explorer_node.has_one_child_folder(node) and node.nodes[1]
|
||||||
if M.config.group_empty and not is_root and child_folder_only then
|
if M.config.group_empty and not is_root and child_folder_only then
|
||||||
|
local child_cwd = child_folder_only.link_to or child_folder_only.absolute_path
|
||||||
|
local child_status = git.load_project_status(child_cwd)
|
||||||
node.group_next = child_folder_only
|
node.group_next = child_folder_only
|
||||||
local ns = M.explore(child_folder_only, status)
|
local ns = M.explore(child_folder_only, child_status)
|
||||||
node.nodes = ns or {}
|
node.nodes = ns or {}
|
||||||
|
|
||||||
log.profile_end(profile)
|
log.profile_end(profile)
|
||||||
|
|||||||
@@ -30,8 +30,30 @@ local function reload_and_get_git_project(path, callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function update_parent_statuses(node, project, root)
|
local function update_parent_statuses(node, project, root)
|
||||||
while project and node and node.absolute_path ~= root do
|
while project and node do
|
||||||
|
-- step up to the containing project
|
||||||
|
if node.absolute_path == root then
|
||||||
|
-- stop at the top of the tree
|
||||||
|
if not node.parent then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
root = git.get_project_root(node.parent.absolute_path)
|
||||||
|
|
||||||
|
-- stop when no more projects
|
||||||
|
if not root then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
-- update the containing project
|
||||||
|
project = git.get_project(root)
|
||||||
|
git.reload_project(root, node.absolute_path, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- update status
|
||||||
explorer_node.update_git_status(node, explorer_node.is_git_ignored(node.parent), project)
|
explorer_node.update_git_status(node, explorer_node.is_git_ignored(node.parent), project)
|
||||||
|
|
||||||
|
-- maybe parent
|
||||||
node = node.parent
|
node = node.parent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user