Closed dansanderson closed 7 years ago
There appears to be a similar issue with the space before "local" getting collapsed.
local x=t[0]local y=1
I submitted a quick fix to always insert a space between closing brackets and names/tokens. The luamin command currently uses a tokens-only approach, so I can't do something more sophisticated like inserting spaces before statements specifically. (There's an AST-based minifier in the code but I gave up on it temporarily because it wasn't producing better results than a tokens-only minifier.) The quick fix should handle the common problem cases, and might actually be a complete fix but I'm not sure. :)
luamin collapses space between non-word characters and keywords. This is mostly correct except it breaks edge cases involving Pico-8's short-if. This feature is invisibly implemented by Pico-8 as a preprocessor replacement, and does not match the "if" if it has a non-word non-space character to its left.
minifies to
which would be correct if the "if" were expanded to its long form, but Pico-8 fails to expand it.
This works:
The workaround is to either avoid short-if, or to make sure that the previous line to a short-if ends in a word char.
luamin should either recognize short-if and preserve the leading space or just always preserve the leading space of the "if" keyword.