fix(file creation): avoid file overwrite and enable creating file on root node (#272)
This commit is contained in:
parent
3350e4e97e
commit
b48274ced0
@ -19,6 +19,13 @@ local function refresh_tree()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function create_file(file)
|
local function create_file(file)
|
||||||
|
if luv.fs_access(file, "r") ~= false then
|
||||||
|
local ans = vim.fn.input(file..' already exists, overwrite ? y/n: ')
|
||||||
|
clear_prompt()
|
||||||
|
if ans ~= "y" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
luv.fs_open(file, "w", open_mode, vim.schedule_wrap(function(err, fd)
|
luv.fs_open(file, "w", open_mode, vim.schedule_wrap(function(err, fd)
|
||||||
if err then
|
if err then
|
||||||
api.nvim_err_writeln('Could not create file '..file)
|
api.nvim_err_writeln('Could not create file '..file)
|
||||||
@ -43,7 +50,12 @@ end
|
|||||||
|
|
||||||
function M.create(node)
|
function M.create(node)
|
||||||
node = lib.get_last_group_node(node)
|
node = lib.get_last_group_node(node)
|
||||||
if node.name == '..' then return end
|
if node.name == '..' then
|
||||||
|
node = {
|
||||||
|
absolute_path = lib.Tree.cwd,
|
||||||
|
entries = lib.Tree.entries,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
local add_into
|
local add_into
|
||||||
if node.entries ~= nil then
|
if node.entries ~= nil then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user