Revert "fix(#1716): focus file/directory when created in a sub-directory, don't dispatch FolderCreated on file creation (#1722)"
This reverts commit bdc4ec6abd.
This commit is contained in:
@@ -2,6 +2,7 @@ local utils = require "nvim-tree.utils"
|
|||||||
local events = require "nvim-tree.events"
|
local events = require "nvim-tree.events"
|
||||||
local lib = require "nvim-tree.lib"
|
local lib = require "nvim-tree.lib"
|
||||||
local core = require "nvim-tree.core"
|
local core = require "nvim-tree.core"
|
||||||
|
local watch = require "nvim-tree.explorer.watch"
|
||||||
local notify = require "nvim-tree.notify"
|
local notify = require "nvim-tree.notify"
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
@@ -98,15 +99,22 @@ function M.fn(node)
|
|||||||
is_error = true
|
is_error = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
events._dispatch_folder_created(path_to_create)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not is_error then
|
if not is_error then
|
||||||
notify.info(new_file_path .. " was properly created")
|
notify.info(new_file_path .. " was properly created")
|
||||||
end
|
end
|
||||||
|
events._dispatch_folder_created(new_file_path)
|
||||||
-- implicitly refreshes contents
|
if M.enable_reload then
|
||||||
require("nvim-tree.actions.finders.find-file").fn(new_file_path)
|
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
|
||||||
|
else
|
||||||
|
-- synchronous call required so that we may focus the file now
|
||||||
|
node = node.nodes ~= nil and node or node.parent
|
||||||
|
if node then
|
||||||
|
watch.refresh_path(node.absolute_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.focus_file(utils.path_remove_trailing(new_file_path))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ local view = require "nvim-tree.view"
|
|||||||
local renderer = require "nvim-tree.renderer"
|
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 log = require "nvim-tree.log"
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@@ -40,16 +39,11 @@ function M.reload_explorer()
|
|||||||
end
|
end
|
||||||
event_running = true
|
event_running = true
|
||||||
|
|
||||||
local ps = log.profile_start "reload_explorer"
|
|
||||||
|
|
||||||
local projects = git.reload()
|
local projects = git.reload()
|
||||||
refresh_nodes(core.get_explorer(), projects)
|
refresh_nodes(core.get_explorer(), projects)
|
||||||
if view.is_visible() then
|
if view.is_visible() then
|
||||||
renderer.draw()
|
renderer.draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
log.profile_end(ps, "reload_explorer")
|
|
||||||
|
|
||||||
event_running = false
|
event_running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,14 +53,9 @@ function M.reload_git()
|
|||||||
end
|
end
|
||||||
event_running = true
|
event_running = true
|
||||||
|
|
||||||
local ps = log.profile_start "reload_git"
|
|
||||||
|
|
||||||
local projects = git.reload()
|
local projects = git.reload()
|
||||||
M.reload_node_status(core.get_explorer(), projects)
|
M.reload_node_status(core.get_explorer(), projects)
|
||||||
renderer.draw()
|
renderer.draw()
|
||||||
|
|
||||||
log.profile_end(ps, "reload_git")
|
|
||||||
|
|
||||||
event_running = false
|
event_running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user