-
Notifications
You must be signed in to change notification settings - Fork 63
XML syntax highlighting fails when double hyphens appear inside multi-line comments #91
Comments
@tommai78101 https://stackoverflow.com/questions/10842131/xml-comments-and I don't know XML, but I'm guessing this is intentional. |
Yeah, I knew about the Stack Overflow, and how it's already in the Opinion section in OP, but I don't know about the last part where leaving out the |
I worked on PR #87 that caused this behavior, it was intentional at the time, but in hindsight I agree with @tommai78101's opinion. However, last time @Ingramz's opinion was that "From the point where the error is first registered, the rest of the document will be invalid." So perhaps we should come to an agreement on what is the best way to do this before I open another PR. |
The If there is a good reason why it should be changed or a reasonable use case that makes the developer experience more comfortable, we can always make the necessary adjustments. |
atom#96 already provides all the details about the issues fixed here. atom#87 (comment) has the correct code but merge included some extra indent which causes the rule not to work properly. In relation with atom#91, a `begin` without `end` or `while` was added but this is not valid as `begin` should always have a corresponding `end` or `while`. `match` should be used instead of `begin`
I've created #101 to address this issue and also #96 I understand the comment above from @Ingramz and the intention to increase visibility on invalid comment is good but current approach blocks highlighting of other parts that are valid or detection of other issues further in the document. Similar to compilers and other grammars, attempting to recover from error and continue parsing translates to better developer experience other than going though all possible issues one by one. A possible midway approach could be to tokeninze with |
My understanding of the problem we are trying to solve now is that people get frustrated when they accidentally leave or type in Now that we have something to solve, I think we should go with the midway approach such that erroneous parts shall not be attempted to highlight correctly at all as proposed by @vfcp. Terminating the comment at the next valid If someone else has any thoughts on this, feel free to provide your take on this. |
So, for the midway approach, I'm proposing adding an Final rule would be:
I'll test this in linguist, vscode's textmate and atom's firstmate before updating my PR. |
@vfcp in general it looks good. The While investigating this, I came up with a slightly different approach to capture the comments: {
'begin': '<!--'
'captures':
'0':
'name': 'punctuation.definition.comment.xml'
'end': '(?<!-)-->'
'name': 'comment.block.xml'
'patterns': [
{
'begin': '--'
'end': '(?=-->)'
'name': 'invalid.illegal.bad-comments-or-CDATA.xml'
}
]
} It should be doing the same thing, but it feels a little cleaner to me. Let me know what you think. |
@Ingramz Your solution works much better with Linguist highlighter and it's also much easier to understand and maintain. The I've updated the PR #101 code and tests accordingly. Thanks a lot for your feedback! |
From @tommai78101 on September 6, 2018 14:13
System Specs
Description
When you put double hyphens (
--
) inside multi-line comment blocks in XML files, it breaks the syntax highlighting.Opinion
Per the following information:
http://www.w3.org/TR/REC-xml/#sec-comments
This is correct indication or correct response to an invalid
--
inside XML comments, however, it should only highlight the offending--
in red, but keep the rest of the code with correct syntax highlighting, so it doesn't highlight the remaining code after the offending--
to be green entirely.Steps to Reproduce:
Image
Does this issue occur when all extensions are disabled?: Yes
Does this issue occur when one of the extensions is disabled?: Yes
Copied from original issue: microsoft/vscode#58076
The text was updated successfully, but these errors were encountered: