diff --git a/Syntaxes/JavaScript Basic.tmLanguage b/Syntaxes/JavaScript Basic.tmLanguage index 541c71f..988d0f9 100644 --- a/Syntaxes/JavaScript Basic.tmLanguage +++ b/Syntaxes/JavaScript Basic.tmLanguage @@ -11,9 +11,19 @@ jsx foldingStartMarker - ^.*(\bfunction\s*(\w+\s*)?\([^\)]*\)(\s*\{[^\}]*)?\s*$)|(={\s*$)|(\({$) + (?x)^ \s* ([^\s].*)? + # Open (nothing | no parens | (no parens? (nested parens ) no parens?)+ ) + ( \[ (?: | (?<noR>[^\[\]]++) | (\g<noR>? (?<round> \[ (?: \g<noR> | \g<round> )* \] ) \g<noR>? )++ ) + | \( (?: | (?<noS>[^\(\)]++) | (\g<noS>? (?<squar> \( (?: \g<noS> | \g<squar> )* \) ) \g<noS>? )++ ) + | \{ (?: | (?<noC>[^\{\}]++) | (\g<noC>? (?<curly> \{ (?: \g<noC> | \g<curly> )* \} ) \g<noC>? )++ ) + )$ foldingStopMarker - (^\s*\})|(^}\)); + (?x)^ \s* + # (nothing | no parens | (no parens? (nested parens ) no parens?)+ ) Close + ( (?: | (?<noR>[^\[\]]++) | (\g<noR>? (?<round> \[ (?: \g<noR> | \g<round> )* \] ) \g<noR>? )++ ) \] + | (?: | (?<noS>[^\(\)]++) | (\g<noS>? (?<squar> \( (?: \g<noS> | \g<squar> )* \) ) \g<noS>? )++ ) \) + | (?: | (?<noC>[^\{\}]++) | (\g<noC>? (?<curly> \{ (?: \g<noC> | \g<curly> )* \} ) \g<noC>? )++ ) \} + ) keyEquivalent ^~J name diff --git a/Tests/Embedded Javascript Test.html b/Tests/Embedded Javascript Test.html index 1c08ebb..8f8d9f1 100644 --- a/Tests/Embedded Javascript Test.html +++ b/Tests/Embedded Javascript Test.html @@ -10,7 +10,7 @@ diff --git a/Tests/Javascript Folding & Indent.js b/Tests/Javascript Folding & Indent.js index 57e442a..8f2b17f 100644 --- a/Tests/Javascript Folding & Indent.js +++ b/Tests/Javascript Folding & Indent.js @@ -46,7 +46,11 @@ myFunction( { label:'value' } -function(){ +var myObj = { + label:'value' +} + +function (){ statement; } @@ -76,6 +80,32 @@ function(){ +// With () +[1,2,3]() +[ + 1, + 2, + 3 +]() +myArray[ + 0 +]() +(statement) +( + statement +)() +myFunction( + statement +)() +{ + label:'value' +}() +function(){ + statement() +}() + + + // Object var myObj = { label: [1,2,3], @@ -263,3 +293,70 @@ var myObj = { /* Comment */ }; /* Comment */ +// ============== +// = Mixed line = +// ============== + +[ [1,2,3],[1,2,3], + [1,2,3],[1,2,3], +][0] +myArray[ myArray[0] + myArray[0] + + 0 +][ 0 +] +( (statement) + + statement +) +myFunction( myFunction() + myFunction() +) +var myObj = { label:{ label:'value' }, label:{ label:'value' }, + label:'value' +} +function(){ function(){ statement }; function(){ statement }; + statement; +} + + +// ======== +// = Bugs = +// ======== + +myFunction() + +myFunction( +)myFunction + +myFunction(() +)myFunction + +myFunction(()() +{()()()())()()} + +myFunction(something() +) + +myFunction(()something +) + +myFunction((something) +) + + myFunction(something(something)something + something(something)something) + + + +myFunction(something()() +) + +myFunction(()something() +) + +myFunction((something)() +) + +myFunction(()something()(something)()something() +) + + + diff --git a/Tests/Javascript Syntax Test.js b/Tests/Javascript Syntax Test.js index 883b24c..2d65146 100644 --- a/Tests/Javascript Syntax Test.js +++ b/Tests/Javascript Syntax Test.js @@ -864,17 +864,21 @@ export import // Labels -checkiandj: +var objectName = { + labelName: "", + labelName2: "" +} +labelName: while (i < 4) { document.write(i + "
"); i += 1; - checkj: + labelName2: while (j > 4) { document.write(j + "
"); j -= 1; if ((j % 2) == 0) - continue checkj; + continue labelName2; document.write(j + " is odd.
"); } document.write("i = " + i + "
"); @@ -887,3 +891,20 @@ new new Function(); new (function(){})(); new(function(){})(); + +// Comments +/**/ +/* */ +/** **/ +// + + +/* +Block Comment +*/ +/** +Documentation Comment (idiom) +**/ +// Inline Comment + +