BowlerHatLLC / vscode-as3mxml

ActionScript & MXML language extension for Visual Studio Code. Develop apps for Adobe AIR, Adobe Flash Player, or Apache Royale.
https://as3mxml.com/
Apache License 2.0
257 stars 39 forks source link

asformat mis-formats MXML Script tag & ignores contents #611

Closed esidegallery closed 1 year ago

esidegallery commented 2 years ago

This is confirmed in a fresh installation of the latest VSCode with the ActionScript & MXML extension on Windows 10 x64.

The opening Script tag is unindented and the ActionScript inside isn't formatted.

MXML Format

esidegallery commented 2 years ago

I've found that if I change the end-of-line sequence option in VS Code from CRLF to LF I can get full formatting to work. However, there seems to be a critical mass of code you can reach which causes the formatter to crash. I've attached the console output below as it's too long to paste:

error.txt

It's hard to determine what exactly causes this threshold to be crossed, as it seems to differ depending on the content of the Script tag. Take the following file (I had to add a .txt extension to get it to upload):

TileList.mxml.txt

Ensuring EOL is set to LF, I can get this file to crash the formatter by duplicating lines in the ListCollection block and then get it to work again by removing lines.

Empty lines don't affect this, but whitespace characters do seem to have an effect.

joshtynjala commented 2 years ago

Thanks. I may not have tested much with CRLF because I tend to avoid it, even on Windows. I'll check that out. I'll also investigate the crash, which seems to be from a regular expression.

esidegallery commented 2 years ago

I admit I never thought to change it from the default 'auto' setting in VS Code, but have done now!

joshtynjala commented 2 years ago

apache/royale-compiler@d76804aae02115dbb76c09eb3b39ab183281da5f

esidegallery commented 1 year ago

Sorry to be a pest, but just wondering if this looks fixable (either the CRLF or LF - whichever is easier!) It would be such a massive enhancement to my workflow if so.

joshtynjala commented 1 year ago

I posted the commit in the Royale compiler where it was fixed. I'm just waiting on the next Royale release to include it in vscode-as3mxml.

esidegallery commented 1 year ago

Awesome! 🎉

esidegallery commented 1 year ago

Josh, it appears that MXML formatting is broken in a similar way for both CRLF and LF style line endings. If the Script contents is too long, formatting breaks, but removing lines will eventually allow it to work. The strange thing is that once it works, I can re-add lines and it will still work - up to a point at least. CRLF seems to be a little more sensitive than LF. This is a Windows PC btw. I'm using the file I posted above for the example below:

Animation

Shall I create a new issue for this?

joshtynjala commented 1 year ago

Yeah, create a new issue. Be sure to click the "Go to output" button and copy the exception that is reported.