diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index f48d03c2..7953d8d3 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -94,11 +94,13 @@ local function do_single_paste(source, dest, action_type, action_fn) end if dest_stats then - vim.ui.select({ "y", "n", "rename" }, { prompt = dest .. " already exists. Overwrite?" }, function(choice) + vim.ui.input({ prompt = dest .. " already exists. Overwrite? y/n/r(ename): " }, function(choice) + utils.clear_prompt() if choice == "y" then on_process() - elseif choice == "rename" then + elseif choice == "r" then vim.ui.input({ prompt = "New name: ", default = dest, completion = "dir" }, function(new_dest) + utils.clear_prompt() if new_dest then do_single_paste(source, new_dest, action_type, action_fn) end diff --git a/lua/nvim-tree/actions/fs/create-file.lua b/lua/nvim-tree/actions/fs/create-file.lua index 7201cb57..055e4552 100644 --- a/lua/nvim-tree/actions/fs/create-file.lua +++ b/lua/nvim-tree/actions/fs/create-file.lua @@ -19,15 +19,12 @@ end local function create_file(file) if utils.file_exists(file) then - vim.ui.select( - { "y", "n" }, - { kind = "confirmation", prompt = file .. " already exists. Overwrite?" }, - function(choice) - if choice == "y" then - create_and_notify(file) - end + vim.ui.input({ prompt = file .. " already exists. Overwrite? y/n: " }, function(choice) + utils.clear_prompt() + if choice == "y" then + create_and_notify(file) end - ) + end) else create_and_notify(file) end @@ -65,6 +62,7 @@ function M.fn(node) local input_opts = { prompt = "Create file ", default = containing_folder, completion = "file" } vim.ui.input(input_opts, function(new_file_path) + utils.clear_prompt() if not new_file_path or new_file_path == containing_folder then return end diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index 6efffbf0..b671bf41 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -68,7 +68,8 @@ function M.fn(node) return end - vim.ui.select({ "y", "n" }, { kind = "confirmation", prompt = "Remove " .. node.name .. " ?" }, function(choice) + vim.ui.input({ prompt = "Remove " .. node.name .. " ? y/n: " }, function(choice) + utils.clear_prompt() if choice == "y" then if node.nodes ~= nil and not node.link_to then local success = remove_dir(node.absolute_path) diff --git a/lua/nvim-tree/actions/fs/rename-file.lua b/lua/nvim-tree/actions/fs/rename-file.lua index 8d771a49..b4ca8e3b 100644 --- a/lua/nvim-tree/actions/fs/rename-file.lua +++ b/lua/nvim-tree/actions/fs/rename-file.lua @@ -38,6 +38,7 @@ function M.fn(with_sub) local input_opts = { prompt = "Rename to ", default = abs_path, completion = "file" } vim.ui.input(input_opts, function(new_file_path) + utils.clear_prompt() if not new_file_path then return end diff --git a/lua/nvim-tree/actions/fs/trash.lua b/lua/nvim-tree/actions/fs/trash.lua index 3550103f..559e6ec1 100644 --- a/lua/nvim-tree/actions/fs/trash.lua +++ b/lua/nvim-tree/actions/fs/trash.lua @@ -93,7 +93,8 @@ function M.fn(node) end if M.config.trash.require_confirm then - vim.ui.select({ "y", "n" }, { kind = "confirmation", prompt = "Trash " .. node.name .. " ?" }, function(choice) + vim.ui.input({ prompt = "Trash " .. node.name .. " ? y/n: " }, function(choice) + utils.clear_prompt() if choice == "y" then do_trash() end diff --git a/lua/nvim-tree/actions/node/open-file.lua b/lua/nvim-tree/actions/node/open-file.lua index 3c4a6f9c..8c736b7a 100644 --- a/lua/nvim-tree/actions/node/open-file.lua +++ b/lua/nvim-tree/actions/node/open-file.lua @@ -112,9 +112,7 @@ local function pick_window() end local _, resp = pcall(get_user_input_char) resp = (resp or ""):upper() - if vim.opt.cmdheight._value ~= 0 then - vim.api.nvim_command "normal! :" - end + utils.clear_prompt() -- Restore window options for _, id in ipairs(selectable) do diff --git a/lua/nvim-tree/marks/bulk-move.lua b/lua/nvim-tree/marks/bulk-move.lua index 3084e263..1cdf4831 100644 --- a/lua/nvim-tree/marks/bulk-move.lua +++ b/lua/nvim-tree/marks/bulk-move.lua @@ -12,6 +12,7 @@ function M.bulk_move() end vim.ui.input({ prompt = "Move to: ", default = Core.get_cwd(), completion = "dir" }, function(location) + utils.clear_prompt() if not location or location == "" then return end diff --git a/lua/nvim-tree/utils.lua b/lua/nvim-tree/utils.lua index c31a6902..33f4f475 100644 --- a/lua/nvim-tree/utils.lua +++ b/lua/nvim-tree/utils.lua @@ -373,4 +373,10 @@ function M.get_win_buf_from_path(path) return nil, nil end +function M.clear_prompt() + if vim.opt.cmdheight._value ~= 0 then + vim.cmd "normal! :" + end +end + return M