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

LSP: Key diagnostics off file path instead of URI #7367

Merged
merged 2 commits into from
Feb 25, 2024

Conversation

the-mikedavis
Copy link
Member

URIs need to be normalized to be comparable. For example a language server could send a URI for a path containing + as %2B but we might encode this in something like Document::url as just +. We can normalize the URI straight into a PathBuf though since this is the only value we compare these diagnostics URIs against. This also covers edge-cases like windows drive letter capitalization.

Closes #3267
Also see #7321 (thanks for the pointer on this @pascalkuthe!)

@the-mikedavis the-mikedavis added C-bug Category: This is a bug A-language-server Area: Language server client S-waiting-on-review Status: Awaiting review from a maintainer. labels Jun 17, 2023
@the-mikedavis the-mikedavis force-pushed the lsp-diagnostics-as-pathbuf branch from f06e53c to 7bbd2d0 Compare June 17, 2023 21:42
Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

helix-term/src/application.rs Outdated Show resolved Hide resolved
@the-mikedavis the-mikedavis force-pushed the lsp-diagnostics-as-pathbuf branch from d0e6a0e to e48f6a0 Compare June 17, 2023 22:04
pascalkuthe
pascalkuthe previously approved these changes Jun 17, 2023
pascalkuthe
pascalkuthe previously approved these changes Jun 20, 2023
pascalkuthe
pascalkuthe previously approved these changes Aug 27, 2023
@pascalkuthe pascalkuthe modified the milestones: next, 23.9 Sep 1, 2023
@the-mikedavis the-mikedavis modified the milestones: 23.10, next Oct 24, 2023
@the-mikedavis the-mikedavis force-pushed the lsp-diagnostics-as-pathbuf branch from fca99c3 to 2425dc7 Compare January 9, 2024 16:30
pascalkuthe
pascalkuthe previously approved these changes Jan 9, 2024
@sbromberger
Copy link
Contributor

This PR might fix the problem where a directory has a + sign: LSP doesn't work in these directories since the URI is normalized/encoded:

helix_lsp::transport [INFO] clangd <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"undeclared_var_use","message":"Use of undeclared identifier 'lkasdjlkasdj'","range":{"end":{"character":14,"line":18},"start":{"character":2,"line":18}},"severity":1,"source":"clang"}],"uri":"file:///home/me/dev/c%2B%2B/advcpp/test.cpp","version":0}}

@kayoscode
Copy link

I'm getting this issue on windows as well. Helix version 23.10

URIs need to be normalized to be comparable. For example a language
server could send a URI for a path containing '+' as '%2B' but we might
encode this in something like 'Document::url' as just '+'. We can
normalize the URI straight into a PathBuf though since this is the only
value we compare these diagnostics URIs against. This also covers
edge-cases like windows drive letter capitalization.
@the-mikedavis
Copy link
Member Author

Yep this should fix how we find the right document for diagnostics for both windows drive letters and any paths that a language server might URL-encode (+, @, etc.)

@the-mikedavis the-mikedavis force-pushed the lsp-diagnostics-as-pathbuf branch from 2425dc7 to fbd31db Compare January 29, 2024 15:16
@gzmorell
Copy link

gzmorell commented Feb 2, 2024

Applying this patch in windows brings diagnosis back. Thanks a lot

@archseer archseer merged commit 928bf80 into master Feb 25, 2024
6 checks passed
@archseer archseer deleted the lsp-diagnostics-as-pathbuf branch February 25, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Looking up diagnostics by URL is ambigous
6 participants