You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My crate has the following structure
workspace-crate (actual rust workspace crate)
- crate1 (part of rust workspace crate, host target)
- crate2 (not part of the rust workspace crate, different target)
Because crate2 has a different target than the workspace crate, I need to setup workspace-lsp-roots (to ["./", "./crate2"]).
Now I get the following behavior:
If I first open crate2/main.rs and then crate1/main.rs everything works fine. Rust-analyzer starts and annotates for me the variables which are unused (that's how I test if it works or not).
However, If I switch it around and first open crate1/main.rs and then crate2/main.rs I loose the annotations of crate2.
I dug into the source code, and it seems that the root_dirs argument of find_lsp_workspace is the problem. If I'm using the problematic order (first crate then crate2), root_dirs is always an empty array. The value is taken from editor::Config::workspace_lsp_roots which is always an empty Vector. It never gets set.
I already have a working fix. However, I'm not familiar with the codebase at all. So I'm not sure if my fix is correct. I will link it under this issue in a couple of minutes. Maybe we can discuss the technical sides of the PR inside the PR then.
Test case which works fine:
Open helix and first open crate2/src/main.rs via the file picker. Wait until rust-analyzer has done it's work, and then you will see a yellow annotation, that the info variable is unused. After that, open crate1/src/main.rs, wait again for the rust-analyzer, and then you will see that the variable unused is annotated.
Test case which doesn't work:
Now do the opposite. Open helix and first open crate1/src/main.rs. You will also see the yellow annotations. Then open crate2/src/main.rs. Wait a while and nothing happens. rust-analyzer is not running on this file.
Helix log
I compared both logs and the following line appears in the working version but not in the not-working version. That's also how I found the right spot in the source code.
Summary
I have set up a POC which illustrates the bug.
The POC can be found here: https://github.com/hieronymusma/poc-helix-workspace-lsp-roots/
My crate has the following structure
workspace-crate (actual rust workspace crate)
-
crate1
(part of rust workspace crate, host target)-
crate2
(not part of the rust workspace crate, different target)Because
crate2
has a different target than the workspace crate, I need to setup workspace-lsp-roots (to["./", "./crate2"]
).Now I get the following behavior:
If I first open
crate2/main.rs
and thencrate1/main.rs
everything works fine. Rust-analyzer starts and annotates for me the variables which are unused (that's how I test if it works or not).However, If I switch it around and first open
crate1/main.rs
and thencrate2/main.rs
I loose the annotations ofcrate2
.I dug into the source code, and it seems that the
root_dirs
argument offind_lsp_workspace
is the problem. If I'm using the problematic order (firstcrate
thencrate2
),root_dirs
is always an empty array. The value is taken fromeditor::Config::workspace_lsp_roots
which is always an empty Vector. It never gets set.I already have a working fix. However, I'm not familiar with the codebase at all. So I'm not sure if my fix is correct. I will link it under this issue in a couple of minutes. Maybe we can discuss the technical sides of the PR inside the PR then.
Thank you already for your time!
Reproduction Steps
Test case which works fine:
Open helix and first open
crate2/src/main.rs
via the file picker. Wait until rust-analyzer has done it's work, and then you will see a yellow annotation, that theinfo
variable is unused. After that, opencrate1/src/main.rs
, wait again for the rust-analyzer, and then you will see that the variableunused
is annotated.Test case which doesn't work:
Now do the opposite. Open helix and first open
crate1/src/main.rs
. You will also see the yellow annotations. Then opencrate2/src/main.rs
. Wait a while and nothing happens. rust-analyzer is not running on this file.Helix log
I compared both logs and the following line appears in the working version but not in the not-working version. That's also how I found the right spot in the source code.
difference.log
Platform
Linux
Terminal Emulator
GNOME Terminal 3.52.0 using VTE 0.76.0 +BIDI +GNUTLS +ICU +SYSTEMD
Installation Method
snap
Helix Version
helix 24.7 (079f544)
The text was updated successfully, but these errors were encountered: