-
-
Notifications
You must be signed in to change notification settings - Fork 287
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: normalizing a relative path returns an absolute path #251
Conversation
This still doesn't work for paths containing both .. parts as well as ...
OK so it's when it finds paths containing plenary.nvim/lua/plenary/path.lua Line 101 in 6bb0e09
|
Maybe I misunderstood, I don't think it's actually a problem with files containing I think it's whenever a path has a
Does anyone know why that logic prepends the |
OK I moved the All tests pass including the 2 new ones I added for testing relative paths |
Also tested it with telescope and it now correctly opens a file named |
I dont know why this was added with this PR #140 Your changes look good to me. Can you fix stylua? Ignore the other CI we dont have a nightly image to pull (again) |
Done! |
Okay i thought about this again and i think that easy. Example i am in /home/conni and do this little script. local Path = require"plenary.path"
local p = Path:new("../../usr/local/share/nvim/runtime/lua/../autoload/ada.vim")
print(vim.inspect(p))
print(p:normalize()) I expect normalize to be Edit: In the object we have the correct value under |
The whole path lib is long overdue for a refactor and splitup into something different. We shouldnt run |
Ah I didn't think of that =\ I'm not sure how you'd know that it should be absolute in that case without comparing it to |
comparing against What we could do is count parts of Does this make sense? |
Got you! I'll have a crack at it |
This should return an absolute path if the initial .. count matches the number of parts in the cwd (Path:_cwd)
OK I think I've got it working now! All previous tests pass and I added two more which should cover the cases you found |
@Conni2461 don't want to bother you but is there anything I can do to help this along? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry i forgot about it 😬
i think this looks good to me but i am not 100% sure its the most optimal solution. We can just try it out 😆
This PR is an attempt to fix #250 which came from this issue in telescope: nvim-telescope/telescope.nvim#1171
The issue is that when a file contains
...
, it ends up prefixed with a/
(probably different on windows but I can't test that). This is a valid filename in frameworks like NextJS (example)The change I made to
path.lua
fixes the issue apart from when the paths also has..
segments. I could use some help figuring that part out. I think it's to do withpath.root()
but I'm not too sure why the behaviour is affected by the filename as I'm on linux and from what I can tell, that will always return/
?Todo
...
, i.e.dir1/[...test].ts
...
and..
segments, i.e.dir1/dir2/../[...test].ts