feat(#2498): delete, trash prompts default N, added ui.confirm.default_yes option to override this behaviour (#2500)
Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
7c5c074354
commit
c1568568b3
@ -573,6 +573,7 @@ Following is the default configuration. See |nvim-tree-opts| for details.
|
|||||||
confirm = {
|
confirm = {
|
||||||
remove = true,
|
remove = true,
|
||||||
trash = true,
|
trash = true,
|
||||||
|
default_yes = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
experimental = {},
|
experimental = {},
|
||||||
@ -1459,6 +1460,10 @@ Confirmation prompts.
|
|||||||
Prompt before trashing.
|
Prompt before trashing.
|
||||||
Type: `boolean`, Default: `true`
|
Type: `boolean`, Default: `true`
|
||||||
|
|
||||||
|
*nvim-tree.ui.confirm.default_yes*
|
||||||
|
If `true` the prompt will be `"Y/n"`, otherwise `"y/N"`.
|
||||||
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5.19 OPTS: EXPERIMENTAL *nvim-tree-opts-experimental*
|
5.19 OPTS: EXPERIMENTAL *nvim-tree-opts-experimental*
|
||||||
|
|
||||||
|
|||||||
@ -595,6 +595,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
confirm = {
|
confirm = {
|
||||||
remove = true,
|
remove = true,
|
||||||
trash = true,
|
trash = true,
|
||||||
|
default_yes = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
experimental = {},
|
experimental = {},
|
||||||
|
|||||||
@ -106,11 +106,22 @@ function M.fn(node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if M.config.ui.confirm.remove then
|
if M.config.ui.confirm.remove then
|
||||||
local prompt_select = "Remove " .. node.name .. " ?"
|
local prompt_select = "Remove " .. node.name .. "?"
|
||||||
local prompt_input = prompt_select .. " y/N: "
|
local prompt_input, items_short, items_long
|
||||||
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
|
|
||||||
|
if M.config.ui.confirm.default_yes then
|
||||||
|
prompt_input = prompt_select .. " Y/n: "
|
||||||
|
items_short = { "", "n" }
|
||||||
|
items_long = { "Yes", "No" }
|
||||||
|
else
|
||||||
|
prompt_input = prompt_select .. " y/N: "
|
||||||
|
items_short = { "", "y" }
|
||||||
|
items_long = { "No", "Yes" }
|
||||||
|
end
|
||||||
|
|
||||||
|
lib.prompt(prompt_input, prompt_select, items_short, items_long, function(item_short)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
if item_short == "y" then
|
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
|
||||||
do_remove()
|
do_remove()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@ -86,11 +86,22 @@ function M.fn(node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if M.config.ui.confirm.trash then
|
if M.config.ui.confirm.trash then
|
||||||
local prompt_select = "Trash " .. node.name .. " ?"
|
local prompt_select = "Trash " .. node.name .. "?"
|
||||||
local prompt_input = prompt_select .. " y/N: "
|
local prompt_input, items_short, items_long
|
||||||
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
|
|
||||||
|
if M.config.ui.confirm.default_yes then
|
||||||
|
prompt_input = prompt_select .. " Y/n: "
|
||||||
|
items_short = { "", "n" }
|
||||||
|
items_long = { "Yes", "No" }
|
||||||
|
else
|
||||||
|
prompt_input = prompt_select .. " y/N: "
|
||||||
|
items_short = { "", "y" }
|
||||||
|
items_long = { "No", "Yes" }
|
||||||
|
end
|
||||||
|
|
||||||
|
lib.prompt(prompt_input, prompt_select, items_short, items_long, function(item_short)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
if item_short == "y" then
|
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
|
||||||
do_trash()
|
do_trash()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user