fix: synchronous file creation
allows cursor to be set when finishing fixes #806
This commit is contained in:
@@ -24,16 +24,13 @@ local function create_file(file)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
uv.fs_open(file, "w", 420, vim.schedule_wrap(function(err, fd)
|
local ok, fd = pcall(uv.fs_open, file, "w", 420)
|
||||||
if err then
|
if not ok then
|
||||||
a.nvim_err_writeln('Couldn\'t create file '..file)
|
a.nvim_err_writeln('Couldn\'t create file '..file)
|
||||||
else
|
return
|
||||||
uv.fs_close(fd)
|
end
|
||||||
events._dispatch_file_created(file)
|
uv.fs_close(fd)
|
||||||
lib.refresh_tree()
|
events._dispatch_file_created(file)
|
||||||
focus_file(file)
|
|
||||||
end
|
|
||||||
end))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_num_entries(iter)
|
local function get_num_entries(iter)
|
||||||
@@ -98,8 +95,9 @@ function M.fn(node)
|
|||||||
a.nvim_out_write(ans..' was properly created\n')
|
a.nvim_out_write(ans..' was properly created\n')
|
||||||
end
|
end
|
||||||
events._dispatch_folder_created(ans)
|
events._dispatch_folder_created(ans)
|
||||||
lib.refresh_tree()
|
lib.refresh_tree(function()
|
||||||
focus_file(ans)
|
focus_file(ans)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ local function refresh_nodes(node, projects)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local event_running = false
|
local event_running = false
|
||||||
function M.refresh_tree()
|
function M.refresh_tree(callback)
|
||||||
if event_running or not M.Tree.cwd or vim.v.exiting ~= vim.NIL then
|
if event_running or not M.Tree.cwd or vim.v.exiting ~= vim.NIL then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -160,6 +160,9 @@ function M.refresh_tree()
|
|||||||
refresh_nodes(M.Tree, projects)
|
refresh_nodes(M.Tree, projects)
|
||||||
if view.win_open() then
|
if view.win_open() then
|
||||||
M.redraw()
|
M.redraw()
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
diagnostics.update()
|
diagnostics.update()
|
||||||
event_running = false
|
event_running = false
|
||||||
|
|||||||
Reference in New Issue
Block a user