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(lspinfo): normalize fname path correctly #2343

Merged
merged 5 commits into from
Feb 15, 2023
Merged

Conversation

musjj
Copy link
Contributor

@musjj musjj commented Dec 23, 2022

vim.fn.fnamemodify and vim.fn.resolve doesn't normalize slashes in Windows paths, which can cause :LspInfo to falsely report that the current attached client is in single file mode.
As far as I know uv.fs_realpath does everything that vim.fn.fnamemodify(..., ":p") and vim.fn.resolve can do and more, so I removed them.

@glepnir
Copy link
Member

glepnir commented Dec 24, 2022

relate #2320 cc @williamboman

@musjj
Copy link
Contributor Author

musjj commented Dec 24, 2022

I guess we can just normalize the slashes manually?

@glepnir
Copy link
Member

glepnir commented Dec 24, 2022

yes. I prefer manually

Copy link
Contributor

@williamboman williamboman left a comment

Choose a reason for hiding this comment

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

Ah, interesting. Maybe we should stick to libuv, but we'll need to default to fname as-is (see #2320)

@@ -112,7 +112,7 @@ local function make_client_info(client, fname)
local workspace_folders = fn.has 'nvim-0.9' == 1 and client.workspace_folders or client.workspaceFolders
local uv = vim.loop
local is_windows = uv.os_uname().version:match 'Windows'
fname = vim.fn.fnamemodify(vim.fn.resolve(fname), ':p')
fname = vim.loop.fs_realpath(fname)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fname = vim.loop.fs_realpath(fname)
fname = vim.loop.fs_realpath(fname) or fname

@musjj
Copy link
Contributor Author

musjj commented Dec 24, 2022

Re-added the previous method as a fallback + a few logic to handle funky separators. What do you think?

Co-authored-by: Raphael <glephunter@gmail.com>
@glepnir glepnir merged commit e20d77d into neovim:master Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants