mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-27 06:30:32 +00:00
Remvoe kruft in [] processing
This commit is contained in:
parent
bc834c8e23
commit
1d3cf832df
48
beautify.js
48
beautify.js
@ -799,7 +799,6 @@ function Beautifier(js_source_text, options) {
|
||||
}
|
||||
|
||||
if (token_text === '[') {
|
||||
|
||||
if (last_type === 'TK_WORD' || last_text === ')') {
|
||||
// this is array index specifier, break immediately
|
||||
// a[x], fn()[x]
|
||||
@ -812,36 +811,19 @@ function Beautifier(js_source_text, options) {
|
||||
}
|
||||
|
||||
if (flags.mode === '[EXPRESSION]' || flags.mode === '[INDENTED-EXPRESSION]') {
|
||||
if (last_last_text === ']' && last_text === ',') {
|
||||
if ((last_text === '[') ||
|
||||
(last_last_text === ']' && last_text === ',')) {
|
||||
// ], [ goes to new line
|
||||
if (flags.mode === '[EXPRESSION]') {
|
||||
flags.mode = '[INDENTED-EXPRESSION]';
|
||||
if (!opt_keep_array_indentation) {
|
||||
if (!opt_keep_array_indentation) {
|
||||
print_newline();
|
||||
if (flags.mode === '[EXPRESSION]') {
|
||||
flags.mode = '[INDENTED-EXPRESSION]';
|
||||
indent();
|
||||
}
|
||||
}
|
||||
set_mode('[EXPRESSION]');
|
||||
if (!opt_keep_array_indentation) {
|
||||
print_newline();
|
||||
}
|
||||
} else if (last_text === '[') {
|
||||
if (flags.mode === '[EXPRESSION]') {
|
||||
flags.mode = '[INDENTED-EXPRESSION]';
|
||||
if (!opt_keep_array_indentation) {
|
||||
indent();
|
||||
}
|
||||
}
|
||||
set_mode('[EXPRESSION]');
|
||||
|
||||
if (!opt_keep_array_indentation) {
|
||||
print_newline();
|
||||
}
|
||||
} else {
|
||||
set_mode('[EXPRESSION]');
|
||||
}
|
||||
} else {
|
||||
set_mode('[EXPRESSION]');
|
||||
}
|
||||
set_mode('[EXPRESSION]');
|
||||
|
||||
} else {
|
||||
if (last_text === 'for') {
|
||||
@ -887,19 +869,11 @@ function Beautifier(js_source_text, options) {
|
||||
}
|
||||
|
||||
function handle_end_expr() {
|
||||
if (token_text === ']') {
|
||||
if (!opt_keep_array_indentation) {
|
||||
if (flags.mode === '[INDENTED-EXPRESSION]') {
|
||||
if (last_text === ']') {
|
||||
restore_mode();
|
||||
print_newline();
|
||||
print_token();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
restore_mode();
|
||||
if (token_text === ']' && !opt_keep_array_indentation &&
|
||||
flags.previous_mode === '[INDENTED-EXPRESSION]' && last_text === ']') {
|
||||
print_newline();
|
||||
}
|
||||
print_token();
|
||||
|
||||
// do {} while () // no statement required after
|
||||
|
Loading…
Reference in New Issue
Block a user