Skip to content

fix: detect the rust-analyzer component in a multi-line components array - #22996

Open
Musteab wants to merge 1 commit into
rust-lang:masterfrom
Musteab:fix-multiline-components-detection
Open

fix: detect the rust-analyzer component in a multi-line components array#22996
Musteab wants to merge 1 commit into
rust-lang:masterfrom
Musteab:fix-multiline-components-detection

Conversation

@Musteab

@Musteab Musteab commented Aug 1, 2026

Copy link
Copy Markdown

Closes #22980

hasToolchainFileWithRaDeclared matched the components array with . between the
brackets. . does not match newlines, so an array written over several lines was never
detected, even though rustup treats it identically to the single line form. Then extension
then fell back to the bundled server, and on a pinned toolchain older than the extension's
minimum supported version that produces a "toolchain too old" modal on every reload, with
nothing in the output channel explaining why the toolchain binary was skipped.

The elements are now matched with [^\]] instead. It crosses newlines but still stops at the
closing bracket, so the match cannot run past the end of the array into an unrelated key. Two
smaller things came with it: TOML literal strings ('rust-analyzer') are accepted, and the
old `?.length === 1 is gone, and a file containing two matching arrays counted as no match
at all.

Selection behaviour is otherwise unchanged. Detection is still opt-in, only when components
explicitly names rust-analyzer, and precedence between the toolchain server and the bundled
one is untouched. Having the component installed without declaring it still does not displace
the bundled server.

The predicate is split out as declaresRaComponent and exposed through the existing _private
object so it can be tested as a plain string check without mocking the filesystem. Tests cover
single line, multi line, literal strings, a components array without rust-analyzer, a file with
no components key, and rust-analyzer appearing outside the array.

🤖 AI-assisted: writing the tests and assisting in the fix

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatting of rust-toolchain.toml should not affect detection of the rust-analyzer component in vscode extension

2 participants