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:
Azad
2023-10-30 02:28:29 +01:00
committed by GitHub
parent 7c5c074354
commit c1568568b3
4 changed files with 36 additions and 8 deletions

View File

@@ -106,11 +106,22 @@ function M.fn(node)
end
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" }, { "No", "Yes" }, function(item_short)
local prompt_select = "Remove " .. node.name .. "?"
local prompt_input, items_short, items_long
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()
if item_short == "y" then
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
do_remove()
end
end)

View File

@@ -86,11 +86,22 @@ function M.fn(node)
end
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" }, { "No", "Yes" }, function(item_short)
local prompt_select = "Trash " .. node.name .. "?"
local prompt_input, items_short, items_long
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()
if item_short == "y" then
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
do_trash()
end
end)