Skip to content

Commit

Permalink
fix(action.move): moving folders (#344)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
jamestrew authored Dec 7, 2023
1 parent afb612a commit 8e05433
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/telescope/_extensions/file_browser/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e05433

Please sign in to comment.