mirror of
https://github.com/beautifier/js-beautify.git
synced 2025-01-31 01:42:23 +00:00
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:
parent
7dca71d9e6
commit
bebfb370f6
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user