Skip to content

Commit 920868d

Browse files
authored
fix(#2370): Better "y/N" prompts (#2377)
* Changed the default y/n prompt to default to N in most cases(all delete cases) and made it so that the copy paste same name conflict defaults to R(ename) * Removed all No conditions as they are not used and not needed * Made item_short into lowercase and also fixed prompts in dressing.nvim and telescope-select.nvim * Fixed the exception which occurs on pressing esc in the prompt and also made rename to be blank or r.*/R.*
1 parent 7c4c7e4 commit 920868d

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

lua/nvim-tree/actions/fs/copy-paste.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ local function do_single_paste(source, dest, action_type, action_fn)
110110
end)
111111
else
112112
local prompt_select = "Overwrite " .. dest .. " ?"
113-
local prompt_input = prompt_select .. " y/n/r(ename): "
114-
lib.prompt(prompt_input, prompt_select, { "y", "n", "r" }, { "Yes", "No", "Rename" }, function(item_short)
113+
local prompt_input = prompt_select .. " R(ename)/y/n: "
114+
lib.prompt(prompt_input, prompt_select, { "", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short)
115115
utils.clear_prompt()
116116
if item_short == "y" then
117117
on_process()
118-
elseif item_short == "r" then
118+
elseif item_short == "" or item_short == "r" then
119119
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
120120
utils.clear_prompt()
121121
if new_dest then

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function M.fn(node)
107107

108108
if M.config.ui.confirm.remove then
109109
local prompt_select = "Remove " .. node.name .. " ?"
110-
local prompt_input = prompt_select .. " y/n: "
111-
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
110+
local prompt_input = prompt_select .. " y/N: "
111+
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
112112
utils.clear_prompt()
113113
if item_short == "y" then
114114
do_remove()

lua/nvim-tree/actions/fs/trash.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function M.fn(node)
8383

8484
if M.config.ui.confirm.trash then
8585
local prompt_select = "Trash " .. node.name .. " ?"
86-
local prompt_input = prompt_select .. " y/n: "
87-
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
86+
local prompt_input = prompt_select .. " y/N: "
87+
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
8888
utils.clear_prompt()
8989
if item_short == "y" then
9090
do_trash()

lua/nvim-tree/lib.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ function M.prompt(prompt_input, prompt_select, items_short, items_long, callback
148148
end)
149149
else
150150
vim.ui.input({ prompt = prompt_input, default = items_short[1] or "" }, function(item_short)
151-
callback(item_short and item_short:sub(1, 1) or nil)
151+
if item_short then
152+
callback(string.lower(item_short and item_short:sub(1, 1)) or nil)
153+
end
152154
end)
153155
end
154156
end

lua/nvim-tree/marks/bulk-delete.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function M.bulk_delete()
3232

3333
if M.config.ui.confirm.remove then
3434
local prompt_select = "Remove bookmarked ?"
35-
local prompt_input = prompt_select .. " y/n: "
36-
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
35+
local prompt_input = prompt_select .. " y/N: "
36+
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
3737
utils.clear_prompt()
3838
if item_short == "y" then
3939
do_delete(nodes)

0 commit comments

Comments
 (0)