-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Html script closing-tag not detected when occurs immediately after 2 slashes #49
Comments
I think this is not a vscode-textmate issue. The problem here is that the html grammar includes |
I posted this issue here on textmate's repository, here is what @infininight commented: So it seams the problem is indeed related to VSCode only!? |
Yes, this is a VS Code only problem that occurs only with the combination of HTML + JS grammars that are shipped with VS Code. The problem does not occur with the HTML + JS grammars that are shipped with TextMate. In other words, it is not a problem with the vscode-textmate (a TM grammar interpreter), but with the grammars and their usage together. |
Still not fixed, WOW! This should be marked as a BUG, since a Closing-Tag after 2 slashes is valid HTML syntax, and so should it be interpreted in VS Code. Who is responsible for this problem? |
So an explanation of this issue so it can better be tracked down: In Javascript generally So the HTML grammar portion of this should be the same in VSCode as far as I know. So I suspect the issue would be on the JavaScript side of the grammar with it's rule matching instead of the special case comment rule. I have very little knowledge of how VSCode is structured so I don't know how JavaScript is handled so further investigations on that side will have to be done by someone else. There is a wider issue of blocks in general being able to break the |
@infininight, please understand that this issue does only occur when the closing tag appears right after the slashes, however if there is a space or any character before the closing tag, it is working properly, see embedded picture, so that's that's confusing, if the problem is because the grammar interprets this full line as a javascript comment why does is not happening even if the closing tag is not immediately after the (//) slashes? |
@SDP190 , the HTML.TMLANGUAGE.JSON file needs the following fix, making line 1850 (from VS Code 127.2) read as: "end": "(?=</script)|(?!\\G)", |
fyi @aeschli . Not sure where we landed on this. Do we now have a special embedded JS grammar that is HTML aware or not? In any case #49 (comment) proposes a change to the html grammar... |
@msftclas I have not tested this in VSCode but I don't see why that would work, unless VSCode doesn't support the In TextMate Now it may be that VSCode doesn't support Since your investigating: |
The reason it was not matching, is because the search term was I wonder if textmate answers the (?!\G) without advancing the cursor? Like maybe its 'looking ahead' to see if the next position would not match the anchor? |
So there are two rules at play here (shown in plist format, technically simplified slightly):
In the first rule we enter the script tag consuming the tags closing
So we enter the second match on the first column of this line for the optional whitespace match. The actual comment interior match starts matching on the
The end of this interior rule is At this point we should have exited the interior rule and should also immediately exit it's parent rule due to it's Advancing the parser to the next column should happen for two reasons: You consume a character or characters advancing the parser to the end of the consumed characters, or after every rule in the active pattern array has been tried and not matched at which point the parser would advance a single character and retry. So I don't know what is tripping up the VSCode parser here. While the fix you cited might work it is not consistant with how the parser should work. Since this basic comment rule structure is used on almost every single TextMate grammar it would be good to track down the actual interaction with the parser that is causing the actual issue so the root cause can be corrected. I'm not at at all familiar enough with how VSCode works to do this tinkering but the way I would do it would be to deconstruct the rules in question to the smallest reproducible test case possible. Because of changes to the |
Okay, the difference I can see with VSCode-TextMate is that the \G anchor point when it hits the I suspect that TextMate's handling of the anchor position (for matching \G) is different when it pop's from a rule, than is VSCode-TextMate's. I know from wondering through some test runs that VSCode's behavior is that if the cursor hasn't advanced past the end of the last BEGIN rule's match, \G is given the match, and that would make a big difference if TextMate treats it, after ENDing a rule, it restores the previous rule's BEGIN match point for the anchor comparison. I could see the syntax (without my proposed change) working in that situation. Here is a debug of vscode (trimmed) ( x,{y} is cursor position {anchor position}, |x| only the active part of the line is shown, and matched: x / y is matched cursor position / final cursor position. )
Notice how in the last segment, the end rule fired, but at position 3, and passed over the
In this case, I am betting that after the BeginEndRule#1043 is popped in TextMate's engine, it reverts the anchor match condition to 0 where the prior lookahead BeginEnd rule matched |
Note, the {anchor position} is my addition in my fork. so I could diagnose an anchor problem. |
@msftrncs Sorry missed your followup question but got pointed to this from a Pug related question. In this example when we exit the comment rule by So I think any issues can be solved by making sure the anchor is cleared when leaving an end and either restoring the parent rules state if any or just removing it entirely. Or to answer your closing question, yes the cc #82 |
Add support for named ref/out arguments
Hi, I found a bug, with the html grammar in VS Code, when you place a closing script-tag in the same line immediately after 2 fwd slashes, as:
<script> //</script>
the grammar will not detect the closing tag, and will display it with wrong color, see images.
(I'm not sure if the issue is related only to vscode-textmate, or it belongs to textmate/html.tmbundle).
VS Code:
Visual Studio 2015:
Steps to Reproduce:
The text was updated successfully, but these errors were encountered: