XML grammar: only the closing --> of a comment gets the scope comment.block.xml
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu với src/TextMateSharp.Grammars/Resources/Grammars/xml/syntaxes/xml.tmLanguage.json, đặc biệt là hai quy tắc chú thích quanh dòng 352–392, rồi so sánh chúng với grammar VS Code được liên kết. Đặt scope của quy tắc thành comment.block.xml và scope của capture kết thúc thành punctuation.definition.comment.xml cho cả hai dạng chú thích. Hoàn tất khi tokenizing một trong hai dạng cho ra các scope như mong đợi được nêu trong issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 170
- Fork
- 35
- Merge trung bình
- 2 giờ 52 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của danipen/TextMateSharp
-
[Breaking]: Visibility of fields/properties/classes does not match upstream tm4e implementationĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
danipen/TextMateSharp#123 · 3 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 44/100
danipen/TextMateSharp#120 · 38 bình luận · 1 reaction ·
-
good first issue
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
danipen/TextMateSharp#119 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
danipen/TextMateSharp#118 · 11 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
danipen/TextMateSharp#75 · 2 bình luận ·
Tất cả issue của danipen/TextMateSharp
Issue tương tự
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Klyroo/klyroo-dashboard#12 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CONTRIBUTING rules Node out in step 0, then tells client-side contributors to run node --test, which is what CI gates onCó thể đã có người làm @yadavraj2001 đã nhận hôm nay. Đang mởdocumentation good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
juandresrodca/AdminForge#73 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[辞書] VIVANTĐang mở要トリアージ 辞書
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
christian-raj/S-Aloha#504 ·
-
Issue: Feature Request Xenonid
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày