-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Looking up diagnostics by URL is ambigous #3267
Comments
Can you post the log when running in verbose mode ( The difference between the workspace and non-workspace pickers is only the filtering of the current LSP URI: helix/helix-term/src/commands/lsp.rs Lines 376 to 422 in e405e88
Seems like the current documents URI is not being detected correctly for you |
I ran helix in verbose mode and have uploaded the log of the run. |
It looks like this file is outside a cargo project's module tree, right? You might be running into rust-analyzer's limitations on non-cargo projects (without extra build info in Can you reproduce this on a file in a cargo project's module tree? |
Ah ok. I can't reproduce this on linux so I think it may be a difference in windows with how we (or rust-analyzer) is tracking URIs. Probably |
I have not managed to reproduce either on macOS and have been using both pickers since they were added to master, so I second the-mikedavis, it's probably a windows-specific bug |
I've managed to reproduce this. I think it's due to the fact that the drive letter has differing case internally in Helix compared to what is being sent by rust-analyzer. This causes the URLs to not be compared equal so the diagnostics are not found. In the general case it will be difficult to know which case the sending LSP will use. I think drive letters in Windows are always upper case, and either way paths are case insensitive. This seems like something that is better solved upstream, the URL crate is simply comparing the serialized URLs (the string representation seen in the logs in this case) for efficiency, but it's unfortunate that this causes problems on Windows. In the meantime if comparing paths is the only way to solve the filtering problem we should probably override the comparisons of URLs and always lower case them. Below is a relevant excerpt from the logs, note the differing case of the drive letter.
|
I went to make an issue on the URL crate and sadly it already implements the spec as written regarding URL comparison. https://url.spec.whatwg.org/#url-equivalence
The remaining options as I see it are either:
Option 1. and 2. might break for other LSP servers. |
Wow good find, that explains why reproducing it failed on macOS and Linux. On the
We don't need to lower all the times, just use use std::path::Path;
fn main() {
let lower = Path::new("c:\\MyPath\\Is\\Here");
let upper = Path::new("C:\\MyPath\\Is\\Here");
dbg!(upper == lower);
for (a, b) in lower.components().zip(upper.components()) {
dbg!(a, b, a == b);
}
} Running this on a Windows VM gives |
Yes, using There is an open issue in the URL standard repo for the windows drive letter whatwg/url#515, but it hasn't seen much activity. |
After some exploration, it could be somewhat hard to fix properly. The following program consider the use std::path::Path;
fn main() {
let url = url::Url::parse("file://C:\\test\\Path").unwrap();
let path = Path::new(url.path());
dbg!(path.components().collect::<Vec<_>>());
let url = url::Url::parse("file://c:\\test\\Path").unwrap();
let path = Path::new(url.path());
dbg!(path.components().collect::<Vec<_>>());
} Run in Windows Powershell: [src/main.rs:6] path.components().collect::<Vec<_>>() = [
RootDir,
Normal(
"C:",
),
Normal(
"test",
),
Normal(
"Path",
),
]
[src/main.rs:10] path.components().collect::<Vec<_>>() = [
RootDir,
Normal(
"c:",
),
Normal(
"test",
),
Normal(
"Path",
),
] Simply lowercasing everything is not valid since filesystems respecting case exist. |
Yeah, either way there's no way of knowing if the URL is targeting a filesystem that is case-insensitive. The only "guaranteed" way of comparing two URLs is to compare whatever they're pointing too, but that is obviously not feasible here. The format for the drive letter is written in the spec and will pretty much always be of the form <ASCII alpha + :> (I've never seen the pipe character be used instead of a colon). If we changed that part of the path to normalize it the rest of the code should work as is. Basically check if the path contains a drive letter and in that case always change it to either upper or lower case. |
I just submitted a PR to fix this. I don't use a Windows machine outside of VMs so if someone who does could test this works for them that would be a nice bonus :) |
I had the issue where Rust LSP did not pick anything. This was because I was not in a cargo project (I guess you call that like that, I'm a newbie in Rust for now). Using a cargo project Helix is able to display errors correctly. Using Arch Linux with |
I am experiencing this same issue. I don't see new commits related to this (correct me if I'm wrong), but I can spend some time looking into this if the discussion in #3347 is still relevant, i.e. the suggestion to convert a |
Summary
Errors do not show up in the local diagnostic picker (Shift g) while writing rust code with the rust analyzer. But they do show up in the global diagnostic picker (Shift G). Screenshots below as an example.
Note that issues are shown in the top right of the screen if my cursor is on the error. As well as indicating the error presence on the left diagnostic gutter.
Code with obvious issues
Empty local diagnostic picker
Global picker has all the errors and warnings.
I found this issue only with rust and rust analyzer. Other languages work well, with file issues in local and workspace issues in the global diagnostic picker.
Helix :
Rust Analyzer:
I have attached helix logs for today and the last time I used helix while omitting the rest as those would be too much. If you need more comprehensive date ranged logs, I'd be happy to provide them.
I don't have much experience with rust so I am not sure if this is a rust issue, a rust analyzer issue, or a helix issue.
Reproduction Steps
I tried this:
hx
I expected this to happen:
The issues in the currently open file to show up there
Instead, this happened:
no errors listed in the local diagnostic picker.
Opening global diagnostic picker (Shift G) shows the errors as expected.
Helix log
~/.cache/helix/helix.log
Platform
Windows
Terminal Emulator
windows terminal 1.14.1963.0
Helix Version
22.05-272-gdfc31e74
The text was updated successfully, but these errors were encountered: