Skip to content

Commit 1cf428a

Browse files
committed
fix(#1615): focus created file when command line prompt requires confirmation
1 parent 6a51945 commit 1cf428a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local utils = require "nvim-tree.utils"
44
local events = require "nvim-tree.events"
55
local lib = require "nvim-tree.lib"
66
local core = require "nvim-tree.core"
7+
local watch = require "nvim-tree.explorer.watch"
78

89
local M = {}
910

@@ -108,7 +109,8 @@ function M.fn(node)
108109
if M.enable_reload then
109110
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
110111
else
111-
require("nvim-tree.explorer.reload").reload(node, {})
112+
-- synchronous call required so that we may focus the file now
113+
watch.refresh_path(node.absolute_path)
112114
end
113115
utils.focus_file(utils.path_remove_trailing(new_file_path))
114116
end)

lua/nvim-tree/explorer/watch.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ local function is_folder_ignored(path)
3939
return false
4040
end
4141

42-
local function refresh_path(path)
42+
function M.refresh_path(path)
4343
log.line("watcher", "node event executing '%s'", path)
4444
local n = utils.get_node_from_path(path)
4545
if not n then
@@ -65,7 +65,7 @@ function M.create_watcher(absolute_path)
6565
local function callback(watcher)
6666
log.line("watcher", "node event scheduled %s", watcher.context)
6767
utils.debounce(watcher.context, M.debounce_delay, function()
68-
refresh_path(watcher._path)
68+
M.refresh_path(watcher._path)
6969
end)
7070
end
7171

0 commit comments

Comments
 (0)