Support multiple inline and block comment styles per language - #664
Draft
Giulia Stocco (gfs) with Copilot wants to merge 3 commits into
Draft
Giulia Stocco (gfs) with Copilot wants to merge 3 commits into
Giulia Stocco (gfs) with Copilot wants to merge 3 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for multiple kinds of block comment pairs
Support multiple inline and block comment styles per language
Sep 15, 2026
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.
Some languages have more than one kind of comment — Razor supports
@* *@,<!-- -->and/* */, Terraform supports#,//and/* */. The comment model allowed exactly one inline marker and one block prefix/suffix pair per language, and commented-state detection searched backwards for that single marker, so it could neither express nor correctly pair these cases.Configuration format (backward compatible)
comments.jsonentries acceptinlines(extra single line markers) andblocks(extra prefix/suffix pairs) alongside the existinginline/prefix/suffix.{ "language": [ "razor" ], "inline": "//", "blocks": [ { "prefix": "@*", "suffix": "*@" }, { "prefix": "<!--", "suffix": "-->" }, { "prefix": "/*", "suffix": "*/" } ] }LanguagesGetCommentInlines(language)/GetCommentBlocks(language)return every style.GetCommentInline/GetCommentPrefix/GetCommentSuffixare retained and return the first style.TextContainercomment scanningCommentedStatesmap) instead of searching backwards from the query index for one known prefix. Ordering makes pairing correct by construction:@* <!-- *@ends at*@, not at-->;/*isn't read as//.ScopeMatch's "language has no block comments → all scopes match" shortcut is unchanged in behavior, keyed off the block list being empty.Default data
terraform:#,//,/* */(previously had no comment definition, so comment scoping was inoperative).html:<!-- -->.razorlanguage for.razor(a previously unmapped extension, so additive) with the three block styles above..cshtmldeliberately stays mapped tohtml; remapping it would silently drophtml-targeted rules, which is the sub-language rule inheritance problem tracked in Paired language rules? #662.Tests
MultipleCommentStylesTestscovers razor block pairing (including cross-style markers and unterminated comments), terraform multi-inline comments, and the newLanguagesaccessors.