Skip to content
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

fix(path): improve & fix bugs in Path:rename() #485

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
9 changes: 0 additions & 9 deletions lua/plenary/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,6 @@ function Path:rename(opts)
-- uses stat)
assert(self_lstat, ("%s: %s"):format(errmsg, self.filename))

-- BUG
-- handles `.`, `..`, `./`, and `../`
if opts.new_name:match "^%.%.?/?\\?.+" then
opts.new_name = {
uv.fs_realpath(opts.new_name:sub(1, 3)),
opts.new_name:sub(4),
}
end

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this as it contains a bug. Secondly, it is unnecessary, as uv.fs_rename already handles such relative paths.

local new_path = Path:new(opts.new_name)
new_lstat, errmsg = uv.fs_lstat(new_path.filename)

Expand Down