Open nene opened 8 years ago
In general, it's unclear what will trigger the pretty-printer, and the pretty-printer is limited with respect to matching code style. It would be useful to be able to explicitly preserve the formatting, or inject formatting.
This also moves comments in odd ways, so
var a = 1, // a
b = 2;
becomes
var // a
a = 1,
b = 2;
We could definitely hack this to work (and I agree there are benefits to avoiding pretty-printing), but I'd like to have a clean/general way to do handle cases like this, where there's a non-identifier token that can change (unlike {
or class
) but doesn't have its own AST node. Gonna have to think about that some more.
Has this ever been resolved?
When running the following program:
I would expect this output:
But instead I get:
Somehow changing the
kind
of a VariableDeclaration removes all the indentation.However, when I change
declarations
of VariableDeclaration in all kinds of ways (without changing the number of items), the formatting is preserved correctly.Interestingly when I add a comment between the declarations, and then change the
kind
, the formatting is preserved.