From 6c860d24b9ba60432704bb2dbb780a01f8c83d94 Mon Sep 17 00:00:00 2001 From: Samuel Durante Date: Fri, 28 Jun 2024 21:15:55 +0000 Subject: [PATCH 1/2] fix(#2813): enable file renaming in `nvim-tree` with changed capitalization --- lua/nvim-tree/actions/fs/rename-file.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/actions/fs/rename-file.lua b/lua/nvim-tree/actions/fs/rename-file.lua index d83f3f53e84..a9bbeb7af28 100644 --- a/lua/nvim-tree/actions/fs/rename-file.lua +++ b/lua/nvim-tree/actions/fs/rename-file.lua @@ -30,13 +30,21 @@ local function err_fmt(from, to, reason) return string.format("Cannot rename %s -> %s: %s", from, to, reason) end +local function rename_file_exists(node, to) + if string.lower(node) == string.lower(to) then + return false + end + + return utils.file_exists(to) +end + ---@param node Node ---@param to string function M.rename(node, to) local notify_from = notify.render_path(node.absolute_path) local notify_to = notify.render_path(to) - if utils.file_exists(to) then + if rename_file_exists(notify_from, notify_to) then notify.warn(err_fmt(notify_from, notify_to, "file already exists")) return end @@ -65,7 +73,7 @@ function M.rename(node, to) notify.warn(err_fmt(notify_from, notify_to, err)) return end - elseif not utils.file_exists(path_to_create) then + elseif not rename_file_exists(notify_from, path_to_create) then local success = vim.loop.fs_mkdir(path_to_create, 493) if not success then notify.error("Could not create folder " .. notify.render_path(path_to_create)) From 1150409119200c552385a9dc48057b8ec5335d95 Mon Sep 17 00:00:00 2001 From: Samuel Durante Date: Wed, 10 Jul 2024 14:25:07 +0000 Subject: [PATCH 2/2] fix(#2813): check if is macos --- lua/nvim-tree/actions/fs/rename-file.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/nvim-tree/actions/fs/rename-file.lua b/lua/nvim-tree/actions/fs/rename-file.lua index a9bbeb7af28..949d41fe695 100644 --- a/lua/nvim-tree/actions/fs/rename-file.lua +++ b/lua/nvim-tree/actions/fs/rename-file.lua @@ -31,6 +31,10 @@ local function err_fmt(from, to, reason) end local function rename_file_exists(node, to) + if not utils.is_macos then + return utils.file_exists(to) + end + if string.lower(node) == string.lower(to) then return false end