From 18d92123e2063d1ba60256e6a8259979c73194c0 Mon Sep 17 00:00:00 2001 From: Mohamed Arish T P Date: Tue, 15 Aug 2023 22:21:49 +0530 Subject: [PATCH 1/4] 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) --- lua/nvim-tree/actions/fs/copy-paste.lua | 4 ++-- lua/nvim-tree/actions/fs/remove-file.lua | 4 ++-- lua/nvim-tree/actions/fs/trash.lua | 4 ++-- lua/nvim-tree/marks/bulk-delete.lua | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index 6c339dc00ae..d51fb636db9 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -110,8 +110,8 @@ 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 .. " y/n/R(ename): " + lib.prompt(prompt_input, prompt_select, { "r", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short) utils.clear_prompt() if item_short == "y" then on_process() diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index d29bd21c4ae..12bc673511a 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -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, { "", "n", "y" }, { "Default(No)", "Yes", "No" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_remove() diff --git a/lua/nvim-tree/actions/fs/trash.lua b/lua/nvim-tree/actions/fs/trash.lua index 00124108ef7..573d03204ea 100644 --- a/lua/nvim-tree/actions/fs/trash.lua +++ b/lua/nvim-tree/actions/fs/trash.lua @@ -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", "n" }, { "Default(No)", "Yes", "No" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_trash() diff --git a/lua/nvim-tree/marks/bulk-delete.lua b/lua/nvim-tree/marks/bulk-delete.lua index 3dd38ea96e4..a2ee26f43ef 100644 --- a/lua/nvim-tree/marks/bulk-delete.lua +++ b/lua/nvim-tree/marks/bulk-delete.lua @@ -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", "n" }, { "Default(No)", "Yes", "No" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_delete(nodes) From 89cce4e411c080f266e7c35da48f36a799826bbd Mon Sep 17 00:00:00 2001 From: Mohamed Arish T P Date: Wed, 16 Aug 2023 21:02:48 +0530 Subject: [PATCH 2/4] Removed all No conditions as they are not used and not needed --- lua/nvim-tree/actions/fs/copy-paste.lua | 4 ++-- lua/nvim-tree/actions/fs/remove-file.lua | 2 +- lua/nvim-tree/actions/fs/trash.lua | 2 +- lua/nvim-tree/marks/bulk-delete.lua | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index d51fb636db9..9d61560d370 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -110,8 +110,8 @@ 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, { "r", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short) + local prompt_input = prompt_select .. " R(ename)/y/n: " + lib.prompt(prompt_input, prompt_select, { "r", "y" }, { "Rename", "Yes" }, function(item_short) utils.clear_prompt() if item_short == "y" then on_process() diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index 12bc673511a..09a8d7288e5 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -108,7 +108,7 @@ 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, { "", "n", "y" }, { "Default(No)", "Yes", "No" }, function(item_short) + lib.prompt(prompt_input, prompt_select, { "", "y" }, { "Default(No)", "Yes" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_remove() diff --git a/lua/nvim-tree/actions/fs/trash.lua b/lua/nvim-tree/actions/fs/trash.lua index 573d03204ea..e4c14087c74 100644 --- a/lua/nvim-tree/actions/fs/trash.lua +++ b/lua/nvim-tree/actions/fs/trash.lua @@ -84,7 +84,7 @@ 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" }, { "Default(No)", "Yes", "No" }, function(item_short) + lib.prompt(prompt_input, prompt_select, { "", "y" }, { "Default(No)", "Yes" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_trash() diff --git a/lua/nvim-tree/marks/bulk-delete.lua b/lua/nvim-tree/marks/bulk-delete.lua index a2ee26f43ef..3206bb35987 100644 --- a/lua/nvim-tree/marks/bulk-delete.lua +++ b/lua/nvim-tree/marks/bulk-delete.lua @@ -33,7 +33,7 @@ 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" }, { "Default(No)", "Yes", "No" }, function(item_short) + lib.prompt(prompt_input, prompt_select, { "", "y" }, { "Default(No)", "Yes" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_delete(nodes) From 78bc56772725328c0389b9f35e16496d1a849bc6 Mon Sep 17 00:00:00 2001 From: Mohamed Arish T P Date: Sun, 20 Aug 2023 11:36:02 +0530 Subject: [PATCH 3/4] Made item_short into lowercase and also fixed prompts in dressing.nvim and telescope-select.nvim --- lua/nvim-tree/actions/fs/copy-paste.lua | 2 +- lua/nvim-tree/actions/fs/remove-file.lua | 2 +- lua/nvim-tree/actions/fs/trash.lua | 2 +- lua/nvim-tree/lib.lua | 2 +- lua/nvim-tree/marks/bulk-delete.lua | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index 9d61560d370..0407d8eba1f 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -111,7 +111,7 @@ local function do_single_paste(source, dest, action_type, action_fn) else local prompt_select = "Overwrite " .. dest .. " ?" local prompt_input = prompt_select .. " R(ename)/y/n: " - lib.prompt(prompt_input, prompt_select, { "r", "y" }, { "Rename", "Yes" }, function(item_short) + lib.prompt(prompt_input, prompt_select, { "r", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short) utils.clear_prompt() if item_short == "y" then on_process() diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index 09a8d7288e5..abc94d4f091 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -108,7 +108,7 @@ 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" }, { "Default(No)", "Yes" }, function(item_short) + lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_remove() diff --git a/lua/nvim-tree/actions/fs/trash.lua b/lua/nvim-tree/actions/fs/trash.lua index e4c14087c74..1db48a20c2a 100644 --- a/lua/nvim-tree/actions/fs/trash.lua +++ b/lua/nvim-tree/actions/fs/trash.lua @@ -84,7 +84,7 @@ 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" }, { "Default(No)", "Yes" }, function(item_short) + lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_trash() diff --git a/lua/nvim-tree/lib.lua b/lua/nvim-tree/lib.lua index 622bf8dbd36..c8717caf038 100644 --- a/lua/nvim-tree/lib.lua +++ b/lua/nvim-tree/lib.lua @@ -148,7 +148,7 @@ 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) + callback(string.lower(item_short and item_short:sub(1, 1)) or nil) end) end end diff --git a/lua/nvim-tree/marks/bulk-delete.lua b/lua/nvim-tree/marks/bulk-delete.lua index 3206bb35987..7a9cb5a0597 100644 --- a/lua/nvim-tree/marks/bulk-delete.lua +++ b/lua/nvim-tree/marks/bulk-delete.lua @@ -33,7 +33,7 @@ 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" }, { "Default(No)", "Yes" }, function(item_short) + lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short) utils.clear_prompt() if item_short == "y" then do_delete(nodes) From 939119dd1550bb1784a7a32c428b9e95886b17c6 Mon Sep 17 00:00:00 2001 From: Mohamed Arish T P Date: Sun, 20 Aug 2023 12:55:24 +0530 Subject: [PATCH 4/4] Fixed the exception which occurs on pressing esc in the prompt and also made rename to be blank or r.*/R.* --- lua/nvim-tree/actions/fs/copy-paste.lua | 4 ++-- lua/nvim-tree/lib.lua | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index 0407d8eba1f..1b26ef12678 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -111,11 +111,11 @@ local function do_single_paste(source, dest, action_type, action_fn) else local prompt_select = "Overwrite " .. dest .. " ?" local prompt_input = prompt_select .. " R(ename)/y/n: " - lib.prompt(prompt_input, prompt_select, { "r", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short) + 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 diff --git a/lua/nvim-tree/lib.lua b/lua/nvim-tree/lib.lua index c8717caf038..66ab0ed5188 100644 --- a/lua/nvim-tree/lib.lua +++ b/lua/nvim-tree/lib.lua @@ -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(string.lower(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