fix(#1716): focus file/directory when created in a sub-directory, don't dispatch FolderCreated on file creation (#1722)

* fix(#1716): focus file/directory when created in a sub-directory, don't dispatch FolderCreated on file creation

* fix(#1716): focus file/directory when created in a sub-directory

* fix(#1716): focus file/directory when created in a sub-directory
This commit is contained in:
Alexander Courtis
2022-11-06 10:08:32 +11:00
committed by GitHub
parent be2ccd4b1a
commit bdc4ec6abd
2 changed files with 15 additions and 12 deletions

View File

@@ -4,7 +4,6 @@ local utils = require "nvim-tree.utils"
local events = require "nvim-tree.events"
local lib = require "nvim-tree.lib"
local core = require "nvim-tree.core"
local watch = require "nvim-tree.explorer.watch"
local notify = require "nvim-tree.notify"
local M = {}
@@ -101,22 +100,15 @@ function M.fn(node)
is_error = true
break
end
events._dispatch_folder_created(path_to_create)
end
end
if not is_error then
notify.info(new_file_path .. " was properly created")
end
events._dispatch_folder_created(new_file_path)
if M.enable_reload then
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))
-- implicitly refreshes contents
require("nvim-tree.actions.finders.find-file").fn(new_file_path)
end)
end