Skip to content

Commit d91b0ab

Browse files
committed
fix(#1716): create-file invokes find-file
1 parent 684a1c2 commit d91b0ab

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

lua/nvim-tree/actions/finders/find-file.lua

+2-7
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ function M.fn(fname)
3030

3131
local ps = log.profile_start("find file %s", fname_real)
3232

33-
if not M.filesystem_watchers_enabled then
34-
reload.refresh_nodes_for_path(vim.fn.fnamemodify(fname_real, ":h"))
35-
end
33+
-- we cannot wait for watchers
34+
reload.refresh_nodes_for_path(vim.fn.fnamemodify(fname_real, ":h"))
3635

3736
local line = core.get_nodes_starting_line()
3837

@@ -75,8 +74,4 @@ function M.fn(fname)
7574
log.profile_end(ps, "find file %s", fname_real)
7675
end
7776

78-
function M.setup(opts)
79-
M.filesystem_watchers_enabled = opts.filesystem_watchers.enabled
80-
end
81-
8277
return M

lua/nvim-tree/actions/fs/create-file.lua

+5-12
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ local utils = require "nvim-tree.utils"
22
local events = require "nvim-tree.events"
33
local lib = require "nvim-tree.lib"
44
local core = require "nvim-tree.core"
5-
local reload = require "nvim-tree.explorer.reload"
65
local notify = require "nvim-tree.notify"
76

7+
local find_file = require("nvim-tree.actions.finders.find-file").fn
8+
89
local M = {}
910

1011
local function create_and_notify(file)
@@ -105,17 +106,9 @@ function M.fn(node)
105106
if not is_error then
106107
notify.info(new_file_path .. " was properly created")
107108
end
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-
reload.refresh_node(node)
115-
end
116-
end
117-
-- TODO #1731 #1716 this gets upset by watcher add new file to linked directories above
118-
utils.focus_file(utils.path_remove_trailing(new_file_path))
109+
110+
-- synchronously refreshes as we can't wait for the watchers
111+
find_file(utils.path_remove_trailing(new_file_path))
119112
end)
120113
end
121114

lua/nvim-tree/actions/init.lua

-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ local DEFAULT_MAPPING_CONFIG = {
385385
}
386386

387387
function M.setup(opts)
388-
require("nvim-tree.actions.finders.find-file").setup(opts)
389388
require("nvim-tree.actions.fs.trash").setup(opts)
390389
require("nvim-tree.actions.node.system-open").setup(opts)
391390
require("nvim-tree.actions.node.file-popup").setup(opts)

0 commit comments

Comments
 (0)