Closed Vasanthi-S closed 8 years ago
we currently don't handle BlockStatement
properly since it ends up being part of many other constructs (like FunctionDeclaration.body
):
function foo() {
// this is also a BlockStatement!
}
To handle it properly we would need to check if the parent node is not a function/do/while/arrowFunction/for/forOf before we add the indent or line breaks.
It is doable (should not be that hard) and is actually something that we need to address, thanks for reporting it!
Thanks for the update. Would be great to know an approximate timeline when this could be fixed.
Hi,
Summary of issue: Standalone block not formatted properly, missing line-breaks and indentations, Creates a erroneous code.
When I have a standalone block with a set of statements, It would be great if it formatted with a line-break after/before block opening/closing brace. Also the statements inside the block needs one-level indentation for readability. Because of the missing line-break, formatter creates a erroneous code output.
Input:
Actual output: - formatter creates errorenous code
After I set the property indent.BlockStatement=1,I get the indentation working (as shown below) With block indentation working:
So in order to get the line-break working, I tried setting lineBreak.before.BlockStatement=1 and lineBreak.after.BlockStatement=1. But do not see linebreaks appearing for the standalone blocks.