Fix hugely ugly regression

Ternary statements made the whole {block} to be treated like 'OBJECT',
leading to a terrible uglineess.
This commit is contained in:
Einar Lielmanis 2010-08-07 02:02:53 +03:00
parent 7dca71d9e6
commit bebfb370f6
2 changed files with 3 additions and 1 deletions

View File

@ -988,8 +988,8 @@ function js_beautify(js_source_text, options) {
space_before = false;
} else if (token_text === ':') {
flags.mode = 'OBJECT';
if (!is_ternary_op()) {
flags.mode = 'OBJECT';
space_before = false;
}
}

View File

@ -323,6 +323,7 @@ function run_beautifier_tests(test_obj)
flags.indent_size = 1;
flags.indent_char = "\t";
bt('{ one_char() }', "{\n\tone_char()\n}");
bt('x = a ? b : c; x;', 'x = a ? b : c;\nx;');
flags.indent_size = 4;
flags.indent_char = ' ';
@ -330,6 +331,7 @@ function run_beautifier_tests(test_obj)
flags.preserve_newlines = false;
bt('var\na=dont_preserve_newlines;', 'var a = dont_preserve_newlines;');
flags.preserve_newlines = true;
bt('var\na=do_preserve_newlines;', 'var\na = do_preserve_newlines;');