rust-lang / rust-lang/rust-analyzer
workspace.discoverConfig only processes one file on startup when multiple undiscovered files are open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Description:
When using the rust-analyzer.workspace.discoverConfig feature, if multiple Rust files that are not part of any currently undiscovered project are open in VSCode on startup or extension reload, only one of these files seems to trigger the discovery command. The other open files remain undiscovered, if not covered by the other discover.
Steps to Reproduce:
-
Configure
rust-analyzer.workspace.discoverConfigwith a command that can output rust-project.json. -
Open multiple Rust files in VSCode, each belonging to different project roots that are not currently known to rust-analyzer.
-
Reload the VSCode window or restart the rust-analyzer extension.
Expected Behavior:
rust-analyzer should trigger the discovery command for each unique project root represented by the open files, or at least queue discovery requests so all opened files eventually get a chance to be discovered.
Actual Behavior:
The discovery command appears to run only for one of the opened files. The other files remain undiscovered, and features like auto-completion, go-to-definition, etc., do not work for them.
I think this is happening because:
- The server-side logic that
triggersTask::DiscoverLinkedProjectswhenCheckIfIndexedfinds an unindexed file, provideddiscoverConfigis set. - The handling of
Task::DiscoverLinkedProjectsincludes a check:!self.discover_workspace_queue.op_in_progress(). - This check seems to prevent more than one discovery operation from running concurrently. On startup, the first file to be processed triggers discovery, and subsequent requests for other open files are effectively ignored because an operation is already in progress.
- This serialization means that the "discover on open" mechanism only works for one project in a multi-project-file startup scenario.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crates/rust-analyzer/src/main_loop.rs at the CheckIfIndexed handling and Task::DiscoverLinkedProjects path, especially the discover_workspace_queue operation check. Reproduce the startup or reload scenario with multiple open Rust files and separate undiscovered project roots. Done means discovery is triggered or queued for each unique root so all opened files become usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100