-
-
Notifications
You must be signed in to change notification settings - Fork 129
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(modules): fix path dissection for windows #76
Conversation
lua/nvchad_ui/tabufline/modules.lua
Outdated
---@type string | ||
local other_filename = api.nvim_buf_get_name(value) | ||
---@type string | ||
local current_filename = api.nvim_buf_get_name(bufnr) | ||
if isWindows then | ||
other_filename = other_filename:gsub("\\", "/") | ||
current_filename = current_filename:gsub("\\", "/") | ||
end |
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.
You can do vim.fs.normalize(filename)
instead of the gsub. It will change all \\
to /
for you
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.
Okay, will try this out and send a new commit
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.
vim.fn.normalize
is perfect. I have removed check for windows as it is not necessary as it deals with both windows and linux cases and also it handled edge cases like "dev\neovim\nvchad-ui/lua/nvchad-ui"
well.
@kingavatar I dont think you need the types here |
Hi guys, I have added a fix where for windows path the breakdown of paths to find similar path was not happening due to windows using "\\" instead of "/" like unix and I have also changed the path display to display single "/" in tab instead of "/../" if the directory is parent itself.
@siduck Yes true, I was getting diagnostic error there before but after updating now I am not getting any errors. I have removed the redundant types defined and pushed again. |
@@ -85,7 +85,13 @@ local function add_fileInfo(name, bufnr) | |||
local other_current = other[i] | |||
|
|||
if value_current ~= other_current then | |||
name = value_current .. "/../" .. name | |||
if (#current - i) < 2 then |
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.
name = value_current .. ((#current - 1) < 2 and "/") or "/../") .. name
Hi guys, I have added a fix where for windows path the breakdown of paths to find similar path was not happening due to windows using "\" instead of "/" like unix path.
So before behavior
After fix
Ihave also encountered cases where the nvim api also sometimes gives path seperator of both types like "dev\neovim\nvchad-ui/lua/nvchad-ui" so I have converted all windows type path to unix path to handle those cases as well.
I have also changed the path display to display single "/" in tab instead of "/../" if the directory is parent itself. I hope this is okay as I thought it may be confusing.