diff --git a/js/lib/beautify.js b/js/lib/beautify.js index 22d78138b..2c113c52d 100644 --- a/js/lib/beautify.js +++ b/js/lib/beautify.js @@ -436,6 +436,10 @@ function indent() { flags.indentation_level += 1; } + + function deindent() { + flags.indentation_level -= 1; + } function set_mode(mode) { if (flags) { @@ -1160,7 +1164,7 @@ print_newline(); if (flags.case_body || opt.jslint_happy) { // switch cases following one another - flags.indentation_level--; + deindent(); flags.case_body = false; } print_token(); diff --git a/python/jsbeautifier/__init__.py b/python/jsbeautifier/__init__.py index 33415df91..b8506739a 100644 --- a/python/jsbeautifier/__init__.py +++ b/python/jsbeautifier/__init__.py @@ -450,6 +450,8 @@ def append_token(self, s): def indent(self): self.flags.indentation_level += 1 + def deindent(self): + self.flags.indentation_level -= 1 def set_mode(self, mode): if self.flags: @@ -990,7 +992,7 @@ def handle_word(self, token_text): self.append_newline() if self.flags.case_body or self.opts.jslint_happy: self.flags.case_body = False - self.flags.indentation_level -= 1 + self.deindent() self.append_token(token_text) self.flags.in_case = True self.flags.in_case_statement = True