XML grammar: only the closing --> of a comment gets the scope comment.block.xml
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
Línea de trabajo
Empieza con src/TextMateSharp.Grammars/Resources/Grammars/xml/syntaxes/xml.tmLanguage.json, especialmente con las dos reglas de comentarios alrededor de las líneas 352–392, y compáralas con la gramática de VS Code enlazada. Establece el scope de la regla como comment.block.xml y el scope de la captura de cierre como punctuation.definition.comment.xml en ambas formas de comentario. El trabajo está terminado cuando la tokenización de cualquiera de las dos formas produce los scopes esperados que se muestran en el issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 170
- Forks
- 35
- Merge medio
- 2 h 52 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de danipen/TextMateSharp
-
[Breaking]: Visibility of fields/properties/classes does not match upstream tm4e implementationAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
danipen/TextMateSharp#123 · 3 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 44/100
danipen/TextMateSharp#120 · 38 comentarios · 1 reacción ·
-
good first issue
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
danipen/TextMateSharp#119 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
danipen/TextMateSharp#118 · 11 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
danipen/TextMateSharp#75 · 2 comentarios ·
Todos los issues de danipen/TextMateSharp
Issues similares
-
good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Klyroo/klyroo-dashboard#12 ·
Los mantenedores suelen responder en 1 día
-
CONTRIBUTING rules Node out in step 0, then tells client-side contributors to run node --test, which is what CI gates onPosiblemente ocupada @yadavraj2001 la tomó hoy. Abiertodocumentation good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
juandresrodca/AdminForge#73 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[辞書] VIVANTAbierto要トリアージ 辞書
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 94/100
christian-raj/S-Aloha#504 ·
-
Issue: Feature Request Xenonid
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día