vincaslt / vscode-highlight-matching-tag

Highlights matching opening or closing tag in VSCode
https://marketplace.visualstudio.com/items?itemName=vincaslt.highlight-matching-tag
MIT License
159 stars 16 forks source link

Invalid syntax error #47

Closed KamasamaK closed 6 years ago

KamasamaK commented 6 years ago

I am very regularly getting an invalid syntax error in CFML files. This most often occurs within <cfset tags, perhaps because the content does not follow the standard attribute/value structure of most tags. Here is a simple example of one of the lines that triggers it: <cfset someFileHash = hash(someFile, "SHA-512")>.

Here is the full error:

ERR invalid syntax at line XX col XXX:

<code line here>

at Lexer.next (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.6.1\node_modules\moo\moo.js:397:13)
at Object.parseTags (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.6.1\out\src\tagParser.js:79:36)
at Object.findMatchingTag (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.6.1\out\src\tagMatcher.js:12:34)
at vscode.window.onDidChangeTextEditorSelection (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.6.1\out\src\extension.js:80:36)
at e.fire (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:99:496)
at e.$acceptEditorPropertiesChanged (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:589:930)
at t._doInvokeHandler (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:640:888)
at t._invokeHandler (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:640:554)
at t._receiveRequest (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:639:126)
at t._receiveOneMessage (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:638:59)
at c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:635:926
at c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:98:138
at e.fire (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:99:496)
at a (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:154:213)
at Socket.n._socketDataListener (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:154:432)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)

Considering the scope of this extension, it doesn't seem necessary that it would need to parse the content of the tag aside from identifying strings to ignore.

vincaslt commented 6 years ago

Thanks for the report, it's a bug in the extension. It's a simple fix it seems.

vincaslt commented 6 years ago

https://github.com/vincaslt/vscode-highlight-matching-tag/commit/3f17e95708faf83a686d1599870d90ef0a22c848

This ought to fix it. I'm closing the issue now, reopen if it still persist with some other cases. You can update the extension in vscode with the change.

KamasamaK commented 6 years ago

I am unable to reopen this issue, but the following line is giving the same error with nearly identical stack trace: <cffile action="read" file="#directory#\#fileName#" variable="localFile">

The backslash seems to be what is causing the issue as it works fine when removed.

Stack trace:

at Lexer.next (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.8.0\node_modules\moo\moo.js:397:13)
at Object.parseTags (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.8.0\out\src\tagParser.js:79:36)
at vscode.window.onDidChangeTextEditorSelection (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.8.0\out\src\extension.js:56:38)
at e.fire (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:99:496)
at e.$acceptEditorPropertiesChanged (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:589:930)
at t._doInvokeHandler (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:640:888)
at t._invokeHandler (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:640:554)
at t._receiveRequest (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:639:126)
at t._receiveOneMessage (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:638:59)
at c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:635:926
at c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:98:138
at e.fire (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:99:496)
at a (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:154:213)
at Socket.n._socketDataListener (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:154:432)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
vincaslt commented 6 years ago

Fixed cases like the above in v0.8.3

KamasamaK commented 6 years ago

I found another case that causes this error. It is multiline strings.

Example:

<cfset sql = "
    SELECT  *
    FROM    SomeTable
">

Stack Trace:

at Lexer._token (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.8.3\node_modules\moo\moo.js:518:13)
at Lexer.next (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.8.3\node_modules\moo\moo.js:465:19)
at Object.parseTags (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.8.3\out\src\tagParser.js:79:36)
at context.subscriptions.push.vscode.window.onDidChangeTextEditorSelection.evt (C:\Users\<User>\.vscode\extensions\vincaslt.highlight-matching-tag-0.8.3\out\src\extension.js:60:36)
at e.fire (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:105:344)
at e.$acceptEditorPropertiesChanged (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:587:404)
at t._doInvokeHandler (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:609:757)
at t._invokeHandler (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:609:423)
at t._receiveRequest (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:608:15)
at t._receiveOneMessage (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:606:957)
at c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:604:773
at c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:103:886
at e.fire (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:105:344)
at a (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:156:881)
at Socket.n._socketDataListener (c:\Users\<User>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:157:95)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
vincaslt commented 6 years ago

Your syntax is really stress-testing the regex rules :D I'm not sure multiline string attributes is something I want to support, because it's not valid html or JSX syntax. I've added the support for them right now, but will only keep it if it doesn't break anything.

KamasamaK commented 6 years ago

Sorry for the unusual cases, but I really appreciate it. I'm not familiar with JSX, but as far as I am aware, line feeds are valid in HTML attribute values.

vincaslt commented 6 years ago

You are right. Apparently you have to use solid tabs for indentation when doing multiline strings in html, probably it would work with spaces too, but they wouldn't be escaped.