Permalink
Browse files

Minor improvement for actionscript

  • Loading branch information...
1 parent b1e925c commit 3f717d38a135175e49c11d855c3eed6a9c5ffe48 @einars einars committed May 18, 2012
Showing with 7 additions and 2 deletions.
  1. +3 −1 beautify.js
  2. +2 −1 python/jsbeautifier/__init__.py
  3. +1 −0 python/jsbeautifier/tests/testjsbeautifier.py
  4. +1 −0 tests/beautify-tests.js
View
@@ -1152,7 +1152,9 @@ function js_beautify(js_source_text, options) {
} else if (token_text === ':') {
if (flags.ternary_depth == 0) {
- flags.mode = 'OBJECT';
+ if (flags.mode == 'BLOCK') {
+ flags.mode = 'OBJECT';
+ }
space_before = false;
} else {
flags.ternary_depth -= 1;
@@ -1034,7 +1034,8 @@ def handle_operator(self, token_text):
elif token_text == ':':
if self.flags.ternary_depth == 0:
- self.flags.mode = 'OBJECT'
+ if self.flags.mode == 'BLOCK':
+ self.flags.mode = 'OBJECT'
space_before = False
else:
self.flags.ternary_depth -= 1
@@ -428,6 +428,7 @@ def test_beautifier(self):
bt('3.*7;', '3. * 7;')
bt('import foo.*;', 'import foo.*;') # actionscript's import
+ test_fragment('function f(a: a, b: b)') # actionscript
def decodesto(self, input, expectation=None):
self.assertEqual(
View
@@ -482,6 +482,7 @@ function run_beautifier_tests(test_obj)
bt('3.*7;', '3. * 7;')
bt('import foo.*;', 'import foo.*;') // actionscript's import
+ test_fragment('function f(a: a, b: b)') // actionscript
return sanitytest;
}

0 comments on commit 3f717d3

Please sign in to comment.