diff --git a/JavaScript/Indentation Rules.tmPreferences b/JavaScript/Indentation Rules.tmPreferences index e3d227d1a05..164335011ac 100644 --- a/JavaScript/Indentation Rules.tmPreferences +++ b/JavaScript/Indentation Rules.tmPreferences @@ -51,10 +51,10 @@ # followed by whitespace or block comments [optional] \g # top-level balanced parentheses - \( - (? (?: + (? + \( (?: # nested balanced parentheses - \( \g \) + \g # double quoted string with ignored escaped quotation marks | \".*(? # anything but closing parenthesis | [^)] - )* ) - # maybe missing, balanced or stray closing parenthesis - \)* + )* \) + ) ) # followed by whitespace or block comments [optional] \g diff --git a/JavaScript/tests/syntax_test_js_indent_common.js b/JavaScript/tests/syntax_test_js_indent_common.js index f5b193640c4..a0e3dc8b5d4 100644 --- a/JavaScript/tests/syntax_test_js_indent_common.js +++ b/JavaScript/tests/syntax_test_js_indent_common.js @@ -668,33 +668,50 @@ function testSwitchCaseIndentationWithLineComments(v) { } // comments } // comments -function testForIndentation(int { +function testForIndentation(v) { - for (int i = 0; i < 10; i++) + for (let i = 0; i < 10; i++) System.out.println("Row " + i); - for (int i = 0; i < 10; i++) { + for (let i = 0; i < 10; i++) { System.out.println("Row " + i); } - for (int i = 0; i < 10; i++) + for (let i = 0; i < 10; i++) { System.out.println("Row " + i); } - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 10; j++) + for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) System.out.println("Row " + i + " Col " + j); } - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 10; j++) { + for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) { System.out.println("Row " + i + " Col " + j); } } + + for ( + let i = 0; + i < 10; + i++) + { + let j = 0; + let k = 0; + } + + for ( + let i = 0; + i < 10; + i++) { + let j = 0; + let k = 0; + } } -function testWhileIndentationNoBraces(int { +function testWhileIndentationNoBraces(v) { while () v++ while () v++; while (()) v++ @@ -722,7 +739,7 @@ function testWhileIndentationNoBraces(int { v++ } -function testWhileIndentationNoBracesButComments(int { +function testWhileIndentationNoBracesButComments(v) { while () v++ // ; "comment" () while () v++; // ; "comment" () while (()) v++ // ; "comment" () @@ -751,7 +768,7 @@ function testWhileIndentationNoBracesButComments(int { while () { } // a hack to make tests succeed } -function testWhileIndentationNoBracesButBlockCommentsPart1(int { +function testWhileIndentationNoBracesButBlockCommentsPart1(v) { while /*(*/ () v++ /*(*/ // ; "comment" () while /*(*/ () v++; /*(*/ // ; "comment" () while /*(*/ (()) v++ /*(*/ // ; "comment" () @@ -780,7 +797,7 @@ function testWhileIndentationNoBracesButBlockCommentsPart1(int { while /*(*/ () { } // a hack to make tests succeed } -function testWhileIndentationNoBracesButBlockCommentsPart2(int { +function testWhileIndentationNoBracesButBlockCommentsPart2(v) { while /*)*/ () v++ /*)*/ // ; "comment" () while /*)*/ () v++; /*)*/ // ; "comment" () while /*)*/ (()) v++ /*)*/ // ; "comment" () @@ -809,7 +826,7 @@ function testWhileIndentationNoBracesButBlockCommentsPart2(int { while /*)*/ () { } // a hack to make tests succeed } -function testWhileIndentationWithBraces(int { +function testWhileIndentationWithBraces(v) { while () { v++ } while () { v++; } @@ -886,9 +903,27 @@ function testWhileIndentationWithBraces(int { { v++ } + while ( + v == foo( bar("") + "" ) + ) + { + v++ + v++ + } + while ( + v == foo( bar("") + "" ) ) { + v++ + v++ + } + while ( + v == foo( bar("") + "" ) + ) { + v++ + v++ + } } -function testWhileIndentationWithBracesAndComments(int { +function testWhileIndentationWithBracesAndComments(v) { while () { v++ } // ; "comments" () while () { v++; } // ; "comments" () @@ -965,4 +1000,22 @@ function testWhileIndentationWithBracesAndComments(int { { // ; "comments" () v++ // ; "comments" () } // ; "comments" () + while ( // ; "comments" () + v == foo( bar("") + "" ) // ; "comments" () + ) // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while ( // ; "comments" () + v == foo( bar("") + "" ) ) { // ; "comments" () + v++ // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while ( // ; "comments" () + v == foo( bar("") + "" ) // ; "comments" () + ) { // ; "comments" () + v++ // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () }