Skip to content

fix(#914): remove existence check before create-file, rename-file, harden clobbered buffer renaming #1977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lua/nvim-tree/actions/fs/create-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ function M.fn(node)
return
end

if utils.file_exists(new_file_path) then
notify.warn "Cannot create: file already exists"
return
end

-- create a folder for each path element if the folder does not exist
-- if the answer ends with a /, create a file for the last path element
local is_last_path_file = not new_file_path:match(utils.path_separator .. "$")
Expand Down
5 changes: 0 additions & 5 deletions lua/nvim-tree/actions/fs/rename-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ local function err_fmt(from, to, reason)
end

function M.rename(node, to)
if utils.file_exists(to) then
notify.warn(err_fmt(node.absolute_path, to, "file already exists"))
return
end

events._dispatch_will_rename_node(node.absolute_path, to)
local success, err = vim.loop.fs_rename(node.absolute_path, to)
if not success then
Expand Down