Skip to content

Commit 16f2806

Browse files
authored
fix: remove redundant file existence check in create file operation (#1936)
1 parent 96506fe commit 16f2806

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,6 @@ local function create_and_notify(file)
1818
events._dispatch_file_created(file)
1919
end
2020

21-
local function create_file(file)
22-
if utils.file_exists(file) then
23-
local prompt_select = "Overwrite " .. file .. " ?"
24-
local prompt_input = prompt_select .. " y/n: "
25-
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
26-
utils.clear_prompt()
27-
if item_short == "y" then
28-
create_and_notify(file)
29-
end
30-
end)
31-
else
32-
create_and_notify(file)
33-
end
34-
end
35-
3621
local function get_num_nodes(iter)
3722
local i = 0
3823
for _ in iter do
@@ -91,7 +76,7 @@ function M.fn(node)
9176
path_to_create = utils.path_join { path_to_create, p }
9277
end
9378
if is_last_path_file and idx == num_nodes then
94-
create_file(path_to_create)
79+
create_and_notify(path_to_create)
9580
elseif not utils.file_exists(path_to_create) then
9681
local success = vim.loop.fs_mkdir(path_to_create, 493)
9782
if not success then

0 commit comments

Comments
 (0)