Permalink
Browse files

for(var a=1,b=2) needless line break fixed.

Expression for (var a=1, b=2..) won't be split into multiple lines
any more.
  • Loading branch information...
1 parent a88de18 commit 372813120252b421b90ba1e0060064f2b189626d @einars einars committed Feb 16, 2009
Showing with 7 additions and 0 deletions.
  1. +3 −0 beautify-tests.js
  2. +4 −0 beautify.js
View
@@ -136,6 +136,9 @@ function test_js_beautify()
bt("var a = x(a, b, c)");
bt("delete x if (a) b();", "delete x\nif (a) b();");
bt("delete x[x] if (a) b();", "delete x[x]\nif (a) b();");
+ bt("for(var a=1,b=2)", "for (var a = 1, b = 2)");
+ bt("for(var a=1,b=2,c=3)", "for (var a = 1, b = 2, c = 3)");
+ bt("for(var a=1,b=2,c=3;d<3;d++)", "for (var a = 1, b = 2, c = 3; d < 3; d++)");
bt("a = 'a'\nb = 'b'");
bt("a = /reg/exp");
View
@@ -520,6 +520,10 @@ function js_beautify(js_source_text, options)
var_line = false;
}
}
+ if (var_line && token_text === ',' && current_mode === 'EXPRESSION') {
+ // do not break on comma, for(var a = 1, b = 2)
+ var_line_tainted = false;
+ }
if (token_text === ':' && in_case) {
print_token(); // colon really asks for separate treatment

0 comments on commit 3728131

Please sign in to comment.