Fix default token metadata for high language IDs#319144
Open
EduardF1 wants to merge 2 commits into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes incorrect default token metadata generation for large language IDs by preventing language ID bits from bleeding into token type bits, and adds a regression test for the scenario.
Changes:
- Mask
topLevelLanguageIdwhen composing default token metadata to keep token type bits correct. - Add regression test covering high language ID values and validating
StandardTokenType.Otheris preserved.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/editor/common/tokens/contiguousTokensStore.ts | Masks language ID bits when computing default metadata to avoid corrupting token type bits. |
| src/vs/editor/test/common/model/tokensStore.test.ts | Adds regression test ensuring default metadata yields StandardTokenType.Other for high language IDs. |
Comment on lines
+592
to
+599
| let languageId = ''; | ||
| for (let i = 0; i < 255; i++) { | ||
| languageId = `language-${i}`; | ||
| codec.register(languageId); | ||
| } | ||
|
|
||
| const encodedLanguageId = codec.encodeLanguageId(languageId); | ||
| assert.ok(encodedLanguageId >= 256); |
Author
There was a problem hiding this comment.
Updated the test to register languages until the encoded ID exceeds MetadataConsts.LANGUAGEID_MASK, so it no longer depends on a hard-coded registration count or codec starting index. Pushed in 31e4cd0.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
|
@microsoft-github-policy-service agree |
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.
Fixes #319118
Masks the encoded language ID before packing default token metadata so IDs above 255 cannot spill into the token type bits. Adds a regression test that exercises a language ID >= 256 and verifies the default token type stays Other.