Index: lib/src/js/printer.dart |
diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart |
index 155ce854febd115c28cde134099c0378b465deba..a7de5939c2da7fc95d32c1ca83c6560ff7596e26 100644 |
--- a/lib/src/js/printer.dart |
+++ b/lib/src/js/printer.dart |
@@ -181,7 +181,16 @@ class Printer implements NodeVisitor { |
void outIndent(String str) { indent(); out(str); } |
void outIndentLn(String str) { indent(); outLn(str); } |
+ |
+ bool _skipNextIndent = false; |
Jennifer Messerly
2015/12/15 23:57:10
style nit: it looks like they're keeping all field
ochafik
2015/12/16 02:00:37
Done.
|
+ void skipNextIndent() { |
+ _skipNextIndent = true; |
+ } |
void indent() { |
+ if (_skipNextIndent) { |
+ _skipNextIndent = false; |
+ return; |
+ } |
if (!shouldCompressOutput) { |
out(indentation); |
} |
@@ -299,8 +308,15 @@ class Printer implements NodeVisitor { |
visitNestedExpression(node.condition, EXPRESSION, |
newInForInit: false, newAtStatementBegin: false); |
out(")"); |
- bool thenWasBlock = |
- blockBody(then, needsSeparation: false, needsNewline: !hasElse); |
+ bool thenWasBlock; |
Jennifer Messerly
2015/12/15 23:57:10
nice readability improvement.
Would it be possibl
ochafik
2015/12/16 02:00:37
Done (didn't realize the contamination potential :
|
+ if (!hasElse && then is! Block) { |
+ thenWasBlock = false; |
+ if (!shouldCompressOutput) spaceOut(); |
Jennifer Messerly
2015/12/15 23:57:10
spaceOut() already does the shouldCompressOutput,
ochafik
2015/12/16 02:00:37
D'oh!
|
+ skipNextIndent(); |
+ visit(then); |
+ } else { |
+ thenWasBlock = blockBody(then, needsSeparation: false, needsNewline: !hasElse); |
Jennifer Messerly
2015/12/15 23:57:10
long line
ochafik
2015/12/16 02:00:37
Done.
|
+ } |
if (hasElse) { |
if (thenWasBlock) { |
spaceOut(); |