mirror of
https://github.com/beautifier/js-beautify.git
synced 2025-02-18 20:28:59 +00:00
Fix rare-ish bug with OBJECT mode
This commit is contained in:
parent
b80ca146e2
commit
8a3123ab9f
@ -936,6 +936,10 @@ function js_beautify(js_source_text, options) {
|
||||
print_token();
|
||||
flags.var_line = false;
|
||||
flags.var_line_reindented = false;
|
||||
if (flags.mode == 'OBJECT') {
|
||||
// OBJECT mode is weird and doesn't get reset too well.
|
||||
flags.mode = 'BLOCK';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'TK_STRING':
|
||||
|
@ -189,7 +189,7 @@ class Beautifier:
|
||||
parser_pos = 0
|
||||
while True:
|
||||
token_text, token_type = self.get_next_token()
|
||||
# print (token_text, token_type, self.flags.mode)
|
||||
#print (token_text, token_type, self.flags.mode)
|
||||
if token_type == 'TK_EOF':
|
||||
break
|
||||
|
||||
@ -859,6 +859,9 @@ class Beautifier:
|
||||
self.append(token_text)
|
||||
self.flags.var_line = False
|
||||
self.flags.var_line_reindented = False
|
||||
if self.flags.mode == 'OBJECT':
|
||||
# OBJECT mode is weird and doesn't get reset too well.
|
||||
self.flags.mode = 'BLOCK'
|
||||
|
||||
|
||||
def handle_string(self, token_text):
|
||||
|
@ -396,6 +396,7 @@ def main():
|
||||
|
||||
bt('if (foo) bar();\nelse break');
|
||||
bt('function x() {\n foo();\n}zzz', 'function x() {\n foo();\n}\nzzz');
|
||||
bt('a: do {} while (); xxx', 'a: do {} while ();\nxxx');
|
||||
|
||||
|
||||
opts.brace_style = "end-expand";
|
||||
|
@ -414,6 +414,7 @@ function run_beautifier_tests(test_obj)
|
||||
|
||||
bt('if (foo) bar();\nelse break');
|
||||
bt('function x() {\n foo();\n}zzz', 'function x() {\n foo();\n}\nzzz');
|
||||
bt('a: do {} while (); xxx', 'a: do {} while ();\nxxx');
|
||||
|
||||
opts.brace_style = "end-expand";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user