@@ -6,18 +6,19 @@ local renderer = require"nvim-tree.renderer"
6
6
7
7
local M = {}
8
8
9
- function M .fn (fname )
10
- local i
9
+ local function get_index_offset ()
11
10
local hide_root_folder = view .View .hide_root_folder
12
- if not TreeExplorer then
13
- return
14
- end
15
11
if TreeExplorer .cwd == ' /' or hide_root_folder then
16
- i = 0
12
+ return 0
17
13
else
18
- i = 1
14
+ return 1
19
15
end
16
+ end
20
17
18
+ function M .fn (fname )
19
+ if not TreeExplorer then return end
20
+
21
+ local i = get_index_offset ()
21
22
local tree_altered = false
22
23
23
24
local function iterate_nodes (nodes )
@@ -27,26 +28,27 @@ function M.fn(fname)
27
28
return i
28
29
end
29
30
30
- local path_matches = utils .str_find (fname , node .absolute_path .. utils .path_separator )
31
+ local path_matches = node . nodes and utils .str_find (fname , node .absolute_path .. utils .path_separator )
31
32
if path_matches then
32
- if # node .nodes == 0 then
33
+ if not node .open then
33
34
node .open = true
34
- explorer_module .explore (node , node .absolute_path , {})
35
+ tree_altered = true
36
+ end
37
+
38
+ if # node .nodes == 0 then
39
+ local git_finished = false
35
40
git .load_project_status (node .absolute_path , function (status )
36
- if status .dirs or status .files then
37
- require " nvim-tree.actions.reloaders" .reload_node_status (node , git .projects )
38
- end
39
- renderer .draw ()
41
+ explorer_module .explore (node , node .absolute_path , status )
42
+ git_finished = true
40
43
end )
44
+ while not vim .wait (10 , function () return git_finished end , 10 ) do end
41
45
end
42
- if node .open == false then
43
- node .open = true
44
- tree_altered = true
45
- end
46
+
46
47
if iterate_nodes (node .nodes ) ~= nil then
47
48
return i
48
49
end
49
- elseif node .open == true then
50
+ -- mandatory to iterate i
51
+ elseif node .open then
50
52
iterate_nodes (node .nodes )
51
53
end
52
54
end
0 commit comments