Skip to content

Commit

Permalink
fix some renaming edgecases
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestrew committed Aug 1, 2024
1 parent 80c133d commit 8b3512a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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 @@ -248,7 +248,9 @@ local batch_rename = function(prompt_bufnr, selections)
for idx, file in ipairs(lines) do
local old = selections[idx]
local new = Path:new(file)
path_map[old] = new
if old.filename ~= new.filename then
path_map[old] = new
end
end
rename_files(path_map)
a.nvim_set_current_win(prompt_win)
Expand Down
14 changes: 9 additions & 5 deletions lua/telescope/_extensions/file_browser/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ local make_entry = function(opts)
local path = Path:new(absolute_path)
local is_dir = path:is_dir()

local e = setmetatable({
local entry = setmetatable({
absolute_path,
ordinal = fb_make_entry_utils.get_ordinal_path(absolute_path, opts.cwd, parent_dir),
Path = path,
Expand All @@ -252,14 +252,18 @@ local make_entry = function(opts)
local cached_entry = opts._entry_cache[absolute_path]
if cached_entry ~= nil then
-- update the entry in-place to keep multi selections in tact
cached_entry.ordinal = e.ordinal
cached_entry.display = e.display
cached_entry.is_dir = is_dir
cached_entry.path = absolute_path
cached_entry.Path = path
cached_entry.ordinal = entry.ordinal
cached_entry.display = entry.display
cached_entry.cwd = opts.cwd

return cached_entry
end

opts._entry_cache[absolute_path] = e
return e -- entry
opts._entry_cache[absolute_path] = entry
return entry
end
end

Expand Down

0 comments on commit 8b3512a

Please sign in to comment.