File tree Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ local utils = require "nvim-tree.utils"
2
2
local events = require " nvim-tree.events"
3
3
local lib = require " nvim-tree.lib"
4
4
local core = require " nvim-tree.core"
5
+ local watch = require " nvim-tree.explorer.watch"
5
6
local notify = require " nvim-tree.notify"
6
7
7
8
local M = {}
@@ -98,15 +99,22 @@ function M.fn(node)
98
99
is_error = true
99
100
break
100
101
end
101
- events ._dispatch_folder_created (path_to_create )
102
102
end
103
103
end
104
104
if not is_error then
105
105
notify .info (new_file_path .. " was properly created" )
106
106
end
107
-
108
- -- implicitly refreshes contents
109
- require (" nvim-tree.actions.finders.find-file" ).fn (new_file_path )
107
+ events ._dispatch_folder_created (new_file_path )
108
+ if M .enable_reload then
109
+ require (" nvim-tree.actions.reloaders.reloaders" ).reload_explorer ()
110
+ else
111
+ -- synchronous call required so that we may focus the file now
112
+ node = node .nodes ~= nil and node or node .parent
113
+ if node then
114
+ watch .refresh_path (node .absolute_path )
115
+ end
116
+ end
117
+ utils .focus_file (utils .path_remove_trailing (new_file_path ))
110
118
end )
111
119
end
112
120
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ local view = require "nvim-tree.view"
3
3
local renderer = require " nvim-tree.renderer"
4
4
local explorer_module = require " nvim-tree.explorer"
5
5
local core = require " nvim-tree.core"
6
- local log = require " nvim-tree.log"
7
6
8
7
local M = {}
9
8
@@ -40,16 +39,11 @@ function M.reload_explorer()
40
39
end
41
40
event_running = true
42
41
43
- local ps = log .profile_start " reload_explorer"
44
-
45
42
local projects = git .reload ()
46
43
refresh_nodes (core .get_explorer (), projects )
47
44
if view .is_visible () then
48
45
renderer .draw ()
49
46
end
50
-
51
- log .profile_end (ps , " reload_explorer" )
52
-
53
47
event_running = false
54
48
end
55
49
@@ -59,14 +53,9 @@ function M.reload_git()
59
53
end
60
54
event_running = true
61
55
62
- local ps = log .profile_start " reload_git"
63
-
64
56
local projects = git .reload ()
65
57
M .reload_node_status (core .get_explorer (), projects )
66
58
renderer .draw ()
67
-
68
- log .profile_end (ps , " reload_git" )
69
-
70
59
event_running = false
71
60
end
72
61
You can’t perform that action at this time.
0 commit comments