XML grammar: only the closing --> of a comment gets the scope comment.block.xml
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
調査の方向性
src/TextMateSharp.Grammars/Resources/Grammars/xml/syntaxes/xml.tmLanguage.jsonから始め、特に352–392行付近の2つのコメントルールを確認し、リンク先のVS Code文法と比較します。どちらのコメント形式についても、ルールのスコープをcomment.block.xmlに、終了キャプチャのスコープをpunctuation.definition.comment.xmlに設定します。どちらの形式をトークン化しても、issueに示された期待どおりのスコープが得られれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
In the XML grammar of TextMateSharp.Grammars, the comment rules (<!-- --> and <%-- --%>) have no name; comment.block.xml is given only to the end capture:
So the opening <!-- and the text of the comment get no comment scope, and a theme colors only the closing -->. In Light+ the comment text stays in the default foreground, and only --> is green. The XSL grammar includes text.xml, so it shows the same.
The grammar comes from atom/language-xml (per cgmanifest.json), where the <!-- rule has "name": "comment.block.xml" and marks both ends as punctuation; VS Code ships it that way:
The file has not changed since 2022-02-15, so 2.0.4, 2.0.5 and 3.0.0-preview.1 ship the same rules.
To Reproduce
RegistryOptions options = new(ThemeName.LightPlus);
IGrammar grammar = new Registry(options).LoadGrammar("text.xml");
foreach (IToken token in grammar.TokenizeLine("<!-- a comment -->").Tokens)
{
Console.WriteLine(string.Join(" ", token.Scopes));
}
Output with TextMateSharp.Grammars 2.0.3:
[<!--] text.xml punctuation.definition.comment.xml
[ a comment ] text.xml
[-->] text.xml comment.block.xml
<%-- a comment --%> gives the same pattern.
Expected behavior
The whole comment has comment.block.xml, and both marks also have punctuation.definition.comment.xml:
[<!--] text.xml comment.block.xml punctuation.definition.comment.xml
[ a comment ] text.xml comment.block.xml
[-->] text.xml comment.block.xml punctuation.definition.comment.xml
Screenshots
None: the token scopes above show it.
Desktop (please complete the following information):
- OS: Windows 11 Pro 10.0.26300 (the grammar is platform independent)
- Version: TextMateSharp.Grammars 2.0.3; master has the same file
Additional context
This change of xml.tmLanguage.json gives the expected output above for both kinds of comments (checked by loading the changed file with LoadGrammarFromPathSync):
"end": "--%>",
"endCaptures": {
"0": {
- "name": "comment.block.xml"
+ "name": "punctuation.definition.comment.xml"
}
- }
+ },
+ "name": "comment.block.xml"
},
"end": "-->",
"endCaptures": {
"0": {
- "name": "comment.block.xml"
+ "name": "punctuation.definition.comment.xml"
}
},
+ "name": "comment.block.xml",
"patterns": [
Until then we repair the raw grammar after reading it: for each rule of repository.comments whose end capture "0" is named comment.block.xml, we set that name on the rule (IRawRule.SetName) and rename the capture to punctuation.definition.comment.xml.
I can open a pull request with this change if that helps.
- 主要言語
- C#
- スター
- 170
- フォーク
- 35
- 平均マージ
- 2時間 52分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
danipen/TextMateSharp のほかの issue
-
[Breaking]: Visibility of fields/properties/classes does not match upstream tm4e implementationオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
danipen/TextMateSharp#123 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 44/100
danipen/TextMateSharp#120 · コメント 38 件 · リアクション 1 件 ·
-
good first issue
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
danipen/TextMateSharp#119 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
danipen/TextMateSharp#118 · コメント 11 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
danipen/TextMateSharp#75 · コメント 2 件 ·
danipen/TextMateSharp の issue をすべて見る
似ている issue
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Klyroo/klyroo-dashboard#12 ·
メンテナーはふだん 1 日以内に返信
-
CONTRIBUTING rules Node out in step 0, then tells client-side contributors to run node --test, which is what CI gates on対応中かも @yadavraj2001 が今日担当しました。 オープンdocumentation good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
juandresrodca/AdminForge#73 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[辞書] VIVANTオープン要トリアージ 辞書
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
christian-raj/S-Aloha#504 ·
-
Issue: Feature Request Xenonid
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信