mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-30 08:00:55 +00:00
parent
3a35ec6fd4
commit
23a6428eef
18
beautify.js
18
beautify.js
@ -1194,18 +1194,20 @@ function js_beautify(js_source_text, options) {
|
||||
// do not break on comma, for(var a = 1, b = 2)
|
||||
flags.var_line_tainted = false;
|
||||
}
|
||||
if (flags.var_line_tainted) {
|
||||
print_token();
|
||||
|
||||
if (flags.var_line) {
|
||||
flags.var_line_reindented = true;
|
||||
flags.var_line_tainted = false;
|
||||
print_newline();
|
||||
break;
|
||||
} else {
|
||||
flags.var_line_tainted = false;
|
||||
}
|
||||
|
||||
print_token();
|
||||
output_space_before_token = true;
|
||||
|
||||
if (flags.var_line_tainted) {
|
||||
flags.var_line_tainted = false;
|
||||
print_newline();
|
||||
} else {
|
||||
output_space_before_token = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,7 @@ function run_beautifier_tests(test_obj)
|
||||
bt("a();\n\nb();", "a();\n\nb();");
|
||||
bt('var a = 1 var b = 2', "var a = 1\nvar b = 2");
|
||||
bt('var a=1, b=c[d], e=6;', 'var a = 1,\n b = c[d],\n e = 6;');
|
||||
bt('var a,\n b,\n c;');
|
||||
bt('a = " 12345 "');
|
||||
bt("a = ' 12345 '");
|
||||
bt('if (a == 1) b = 2;', "if (a == 1) b = 2;");
|
||||
@ -316,8 +317,7 @@ function run_beautifier_tests(test_obj)
|
||||
bt('if (a) a()\nnewline()');
|
||||
bt('a=typeof(x)', 'a = typeof(x)');
|
||||
|
||||
// known problem, the next "b = false" has insufficient indentation:
|
||||
bt('var a = function() {\n return null;\n},\nb = false;');
|
||||
bt('var a = function() {\n return null;\n},\n b = false;');
|
||||
|
||||
bt('var a = function() {\n func1()\n}');
|
||||
bt('var a = function() {\n func1()\n}\nvar b = function() {\n func2()\n}');
|
||||
|
Loading…
Reference in New Issue
Block a user