vscode-as3mxml icon indicating copy to clipboard operation
vscode-as3mxml copied to clipboard

asformat mis-formats MXML Script tag & ignores contents

Open esidegallery opened this issue 2 years ago • 4 comments

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 avatar Jul 18 '22 09:07 esidegallery

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.

esidegallery avatar Jul 21 '22 15:07 esidegallery

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.

joshtynjala avatar Jul 21 '22 18:07 joshtynjala

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

esidegallery avatar Jul 22 '22 09:07 esidegallery

apache/royale-compiler@d76804aae02115dbb76c09eb3b39ab183281da5f

joshtynjala avatar Jul 28 '22 22:07 joshtynjala

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.

esidegallery avatar Apr 04 '23 09:04 esidegallery

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.

joshtynjala avatar Apr 04 '23 14:04 joshtynjala

Awesome! 🎉

esidegallery avatar May 31 '23 07:05 esidegallery

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?

esidegallery avatar Aug 04 '23 09:08 esidegallery

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

joshtynjala avatar Aug 04 '23 15:08 joshtynjala