Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Expose scope comments in IToken #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
Copilot wants to merge 4 commits into main
base: main
Choose a base branch
Loading
from copilot/expose-scope-comment-in-itoken

Conversation

Copy link

Copilot AI commented Dec 8, 2025
edited
Loading

TextMate grammars support a comment field on rules for documentation purposes. This field was being parsed but not exposed to consumers, making it inaccessible to tools like VS Code's scope inspector.

Changes

Type System

  • Added optional comment field to IRawRule interface
  • Added scopeComments: (string | null)[] to IToken interface, parallel to existing scopes array

Rule Storage

  • Updated Rule base class and all subclasses (CaptureRule, MatchRule, IncludeOnlyRule, BeginEndRule, BeginWhileRule) to store and expose comments via getComment() method
  • Modified RuleFactory to extract comment field from grammar rules during compilation

Scope Stack

  • Extended ScopeStack to track scopeComment alongside scopeName, added getComments() method
  • Updated AttributedScopeStack.pushAttributed() to accept and propagate comment parameter
  • For multi-scope pushes (space-separated scopes), comment is assigned to first scope only

Tokenization

  • Modified tokenization logic to retrieve comments from rules and pass through pushAttributed() calls
  • Token creation now includes scope comments array matching scope hierarchy

Example

// Grammar with comments
{
 "match": "\\b(hello)\\b",
 "name": "keyword.test",
 "comment": "Matches the hello keyword"
}
// Resulting token
{
 scopes: ["source.test", "keyword.test"],
 scopeComments: [null, "Matches the hello keyword"]
}

Comments default to null when not present, maintaining backward compatibility.

Original prompt

This section details on the original issue you should resolve

<issue_title>Expose scope comment in IToken</issue_title>
<issue_description>There's a feature request in VS Code to include grammar scope comments in microsoft/vscode#206192. First, the scope comments need to be exposed in IToken in vscode-textmate. </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

RedCMD reacted with thumbs up emoji
Copilot AI and others added 3 commits December 8, 2025 11:30
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title (削除) [WIP] Expose scope comment in IToken for vscode-textmate (削除ここまで) (追記) Expose scope comments in IToken (追記ここまで) Dec 8, 2025
Copilot AI requested a review from alexr00 December 8, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alexr00 alexr00 Awaiting requested review from alexr00

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Expose scope comment in IToken

2 participants

AltStyle によって変換されたページ (->オリジナル) /