From d0474e581275f6ecef4dcef8c85752b31114b9df Mon Sep 17 00:00:00 2001 From: James Trew Date: Sat, 2 Dec 2023 20:04:29 -0500 Subject: [PATCH] fix(action.move): moving folders `vim.fs.basename("/foo/bar/)` returns an empty string. This behavior differs from the unix `basename` program which returns `bar`. Just need to accommodate for this. --- lua/telescope/_extensions/file_browser/actions.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/telescope/_extensions/file_browser/actions.lua b/lua/telescope/_extensions/file_browser/actions.lua index 8543e7b6..79433240 100755 --- a/lua/telescope/_extensions/file_browser/actions.lua +++ b/lua/telescope/_extensions/file_browser/actions.lua @@ -346,8 +346,10 @@ fb_actions.move = function(prompt_bufnr) local skipped = {} for idx, selection in ipairs(selections) do - -- use vim.fs rather than plenary to fetch basename, more battle-tested local old_path_absolute = selection:absolute() + if vim.fn.isdirectory(old_path_absolute) == 1 then + old_path_absolute = vim.fs.dirname(old_path_absolute) + end local basename = vim.fs.basename(old_path_absolute) local new_path = Path:new { target_dir, basename } if new_path:exists() then