File tree Expand file tree Collapse file tree 3 files changed +39
-10
lines changed Expand file tree Collapse file tree 3 files changed +39
-10
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,22 @@ local renderer = require "nvim-tree.renderer"
4
4
local explorer_module = require " nvim-tree.explorer"
5
5
local core = require " nvim-tree.core"
6
6
local explorer_node = require " nvim-tree.explorer.node"
7
+ local Iterator = require " nvim-tree.iterators.node-iterator"
7
8
8
9
local M = {}
9
10
10
11
local function refresh_nodes (node , projects , unloaded_bufnr )
11
- local cwd = node .cwd or node .link_to or node .absolute_path
12
- local project_root = git .get_project_root (cwd )
13
- explorer_module .reload (node , projects [project_root ] or {}, unloaded_bufnr )
14
- for _ , _node in ipairs (node .nodes ) do
15
- if _node .nodes and _node .open then
16
- refresh_nodes (_node , projects , unloaded_bufnr )
17
- end
18
- end
12
+ Iterator .builder ({ node })
13
+ :applier (function (n )
14
+ if n .open and n .nodes then
15
+ local project_root = git .get_project_root (n .cwd or n .link_to or n .absolute_path )
16
+ explorer_module .reload (n , projects [project_root ] or {}, unloaded_bufnr )
17
+ end
18
+ end )
19
+ :recursor (function (n )
20
+ return n .group_next and { n .group_next } or (n .open and n .nodes )
21
+ end )
22
+ :iterate ()
19
23
end
20
24
21
25
function M .reload_node_status (parent_node , projects )
Original file line number Diff line number Diff line change 1
1
local utils = require " nvim-tree.utils"
2
2
local builders = require " nvim-tree.explorer.node-builders"
3
3
local explorer_node = require " nvim-tree.explorer.node"
4
+ local git = require " nvim-tree.git"
4
5
local sorters = require " nvim-tree.explorer.sorters"
5
6
local filters = require " nvim-tree.explorer.filters"
6
7
local live_filter = require " nvim-tree.live-filter"
@@ -70,8 +71,10 @@ function M.explore(node, status)
70
71
local is_root = not node .parent
71
72
local child_folder_only = explorer_node .has_one_child_folder (node ) and node .nodes [1 ]
72
73
if M .config .group_empty and not is_root and child_folder_only then
74
+ local child_cwd = child_folder_only .link_to or child_folder_only .absolute_path
75
+ local child_status = git .load_project_status (child_cwd )
73
76
node .group_next = child_folder_only
74
- local ns = M .explore (child_folder_only , status )
77
+ local ns = M .explore (child_folder_only , child_status )
75
78
node .nodes = ns or {}
76
79
77
80
log .profile_end (profile )
Original file line number Diff line number Diff line change @@ -30,8 +30,30 @@ local function reload_and_get_git_project(path, callback)
30
30
end
31
31
32
32
local function update_parent_statuses (node , project , root )
33
- while project and node and node .absolute_path ~= root do
33
+ while project and node do
34
+ -- step up to the containing project
35
+ if node .absolute_path == root then
36
+ -- stop at the top of the tree
37
+ if not node .parent then
38
+ break
39
+ end
40
+
41
+ root = git .get_project_root (node .parent .absolute_path )
42
+
43
+ -- stop when no more projects
44
+ if not root then
45
+ break
46
+ end
47
+
48
+ -- update the containing project
49
+ project = git .get_project (root )
50
+ git .reload_project (root , node .absolute_path , nil )
51
+ end
52
+
53
+ -- update status
34
54
explorer_node .update_git_status (node , explorer_node .is_git_ignored (node .parent ), project )
55
+
56
+ -- maybe parent
35
57
node = node .parent
36
58
end
37
59
end
You can’t perform that action at this time.
0 commit comments