From 9c92fe11bb293453a6f4df0992f1bbaa6da9687d Mon Sep 17 00:00:00 2001 From: yioneko Date: Mon, 23 Jan 2023 11:17:02 +0800 Subject: [PATCH] fix: remove redundant file existence check in create file operation --- lua/nvim-tree/actions/fs/create-file.lua | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lua/nvim-tree/actions/fs/create-file.lua b/lua/nvim-tree/actions/fs/create-file.lua index c970eeddab5..cd0a83800f1 100644 --- a/lua/nvim-tree/actions/fs/create-file.lua +++ b/lua/nvim-tree/actions/fs/create-file.lua @@ -18,21 +18,6 @@ local function create_and_notify(file) events._dispatch_file_created(file) end -local function create_file(file) - if utils.file_exists(file) then - local prompt_select = "Overwrite " .. file .. " ?" - local prompt_input = prompt_select .. " y/n: " - lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short) - utils.clear_prompt() - if item_short == "y" then - create_and_notify(file) - end - end) - else - create_and_notify(file) - end -end - local function get_num_nodes(iter) local i = 0 for _ in iter do @@ -91,7 +76,7 @@ function M.fn(node) path_to_create = utils.path_join { path_to_create, p } end if is_last_path_file and idx == num_nodes then - create_file(path_to_create) + create_and_notify(path_to_create) elseif not utils.file_exists(path_to_create) then local success = vim.loop.fs_mkdir(path_to_create, 493) if not success then