Skip to content

fix(#2370): Better "y/N" prompts #2377

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 5 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions lua/nvim-tree/actions/fs/copy-paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ local function do_single_paste(source, dest, action_type, action_fn)
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)
local prompt_input = prompt_select .. " R(ename)/y/n: "
lib.prompt(prompt_input, prompt_select, { "", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short)
utils.clear_prompt()
if item_short == "y" then
on_process()
elseif item_short == "r" then
elseif item_short == "" or item_short == "r" then
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
utils.clear_prompt()
if new_dest then
Expand Down
4 changes: 2 additions & 2 deletions lua/nvim-tree/actions/fs/remove-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ function M.fn(node)

if M.config.ui.confirm.remove then
local prompt_select = "Remove " .. node.name .. " ?"
local prompt_input = prompt_select .. " y/n: "
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
local prompt_input = prompt_select .. " y/N: "
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
utils.clear_prompt()
if item_short == "y" then
do_remove()
Expand Down
4 changes: 2 additions & 2 deletions lua/nvim-tree/actions/fs/trash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ function M.fn(node)

if M.config.ui.confirm.trash then
local prompt_select = "Trash " .. node.name .. " ?"
local prompt_input = prompt_select .. " y/n: "
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
local prompt_input = prompt_select .. " y/N: "
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
utils.clear_prompt()
if item_short == "y" then
do_trash()
Expand Down
4 changes: 3 additions & 1 deletion lua/nvim-tree/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ function M.prompt(prompt_input, prompt_select, items_short, items_long, callback
end)
else
vim.ui.input({ prompt = prompt_input, default = items_short[1] or "" }, function(item_short)
callback(item_short and item_short:sub(1, 1) or nil)
if item_short then
callback(string.lower(item_short and item_short:sub(1, 1)) or nil)
end
end)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lua/nvim-tree/marks/bulk-delete.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function M.bulk_delete()

if M.config.ui.confirm.remove then
local prompt_select = "Remove bookmarked ?"
local prompt_input = prompt_select .. " y/n: "
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
local prompt_input = prompt_select .. " y/N: "
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
utils.clear_prompt()
if item_short == "y" then
do_delete(nodes)
Expand Down