Skip to content

Commit 6c860d2

Browse files
fix(#2813): enable file renaming in nvim-tree with changed capitalization
1 parent 8b2c5c6 commit 6c860d2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lua/nvim-tree/actions/fs/rename-file.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@ local function err_fmt(from, to, reason)
3030
return string.format("Cannot rename %s -> %s: %s", from, to, reason)
3131
end
3232

33+
local function rename_file_exists(node, to)
34+
if string.lower(node) == string.lower(to) then
35+
return false
36+
end
37+
38+
return utils.file_exists(to)
39+
end
40+
3341
---@param node Node
3442
---@param to string
3543
function M.rename(node, to)
3644
local notify_from = notify.render_path(node.absolute_path)
3745
local notify_to = notify.render_path(to)
3846

39-
if utils.file_exists(to) then
47+
if rename_file_exists(notify_from, notify_to) then
4048
notify.warn(err_fmt(notify_from, notify_to, "file already exists"))
4149
return
4250
end
@@ -65,7 +73,7 @@ function M.rename(node, to)
6573
notify.warn(err_fmt(notify_from, notify_to, err))
6674
return
6775
end
68-
elseif not utils.file_exists(path_to_create) then
76+
elseif not rename_file_exists(notify_from, path_to_create) then
6977
local success = vim.loop.fs_mkdir(path_to_create, 493)
7078
if not success then
7179
notify.error("Could not create folder " .. notify.render_path(path_to_create))

0 commit comments

Comments
 (0)