Skip to content

feat(#2277): skip overwrite prompt when copy/cut paste into same directory #2278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions lua/nvim-tree/actions/fs/copy-paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,30 @@ local function do_single_paste(source, dest, action_type, action_fn)
end

if dest_stats then
local prompt_select = "Overwrite " .. dest .. " ?"
local prompt_input = prompt_select .. " y/n/r(ename): "
lib.prompt(prompt_input, prompt_select, { "y", "n", "r" }, { "Yes", "No", "Rename" }, function(item_short)
utils.clear_prompt()
if item_short == "y" then
on_process()
elseif item_short == "r" then
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
utils.clear_prompt()
if new_dest then
do_single_paste(source, new_dest, action_type, action_fn)
end
end)
end
end)
if source == dest then
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
utils.clear_prompt()
if new_dest then
do_single_paste(source, new_dest, action_type, action_fn)
end
end)
else
local prompt_select = "Overwrite " .. dest .. " ?"
local prompt_input = prompt_select .. " y/n/r(ename): "
lib.prompt(prompt_input, prompt_select, { "y", "n", "r" }, { "Yes", "No", "Rename" }, function(item_short)
utils.clear_prompt()
if item_short == "y" then
on_process()
elseif item_short == "r" then
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
utils.clear_prompt()
if new_dest then
do_single_paste(source, new_dest, action_type, action_fn)
end
end)
end
end)
end
else
on_process()
end
Expand Down