From 80a63b7cfae086965d8629a4808490ace524746e Mon Sep 17 00:00:00 2001 From: Einar Lielmanis Date: Fri, 18 Sep 2009 15:07:46 +0300 Subject: [PATCH] Fixed array indentation regressions. Was: { [x()[x]]; indent; } Is: { [x()[x]]; indent; } --- beautify-tests.js | 11 +++++++++++ beautify.js | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/beautify-tests.js b/beautify-tests.js index 0f43b677..d33515be 100644 --- a/beautify-tests.js +++ b/beautify-tests.js @@ -214,6 +214,17 @@ function test_js_beautify() bt('[[["1","2"],["3","4"]],[["5","6","7"],["8","9","0"]],[["1","2","3"],["4","5","6","7"],["8","9","0"]]]', '[\n [\n ["1", "2"],\n ["3", "4"]],\n [\n ["5", "6", "7"],\n ["8", "9", "0"]],\n [\n ["1", "2", "3"],\n ["4", "5", "6", "7"],\n ["8", "9", "0"]]]'); + bt('{[x()[0]];indent;}', '{\n [x()[0]];\n indent;\n}'); + +function foo(sQuery, oResponse, oPayload, o) { + if (oResponse.results.length < 10) { + for (var i = 0; i < test.ac.people1.length; i++) { + var uname = [test.ac.people1[i].split("\t")[0], +test.ac.people1[i].split("\t")[1]]; + oResponse.results.push(uname); + } + } +} space_after_anon_function = true; diff --git a/beautify.js b/beautify.js index b10d0603..f813c1ba 100644 --- a/beautify.js +++ b/beautify.js @@ -486,8 +486,9 @@ function js_beautify(js_source_text, options) if (token_text === '[') { - if (last_type === 'TK_WORD') { + if (last_type === 'TK_WORD' || last_text === ')') { // this is array index specifier, break immediately + // a[x], fn()[x] set_mode('(EXPRESSION)'); print_token(); break;