fix: detect the rust-analyzer component in a multi-line components array - #22996
Open
Musteab wants to merge 1 commit into
Open
fix: detect the rust-analyzer component in a multi-line components array#22996Musteab wants to merge 1 commit into
Musteab wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22980
hasToolchainFileWithRaDeclaredmatched thecomponentsarray with.between thebrackets.
.does not match newlines, so an array written over several lines was neverdetected, 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 theclosing 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 theold `?.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
componentsexplicitly names
rust-analyzer, and precedence between the toolchain server and the bundledone is untouched. Having the component installed without declaring it still does not displace
the bundled server.
The predicate is split out as
declaresRaComponentand exposed through the existing_privateobject 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