Skip to content

Commit 8e05433

Browse files
authored
fix(action.move): moving folders (#344)
`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.
1 parent afb612a commit 8e05433

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lua/telescope/_extensions/file_browser/actions.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,10 @@ fb_actions.move = function(prompt_bufnr)
346346
local skipped = {}
347347

348348
for idx, selection in ipairs(selections) do
349-
-- use vim.fs rather than plenary to fetch basename, more battle-tested
350349
local old_path_absolute = selection:absolute()
350+
if vim.fn.isdirectory(old_path_absolute) == 1 then
351+
old_path_absolute = vim.fs.dirname(old_path_absolute)
352+
end
351353
local basename = vim.fs.basename(old_path_absolute)
352354
local new_path = Path:new { target_dir, basename }
353355
if new_path:exists() then

0 commit comments

Comments
 (0)