Skip to content

Commit

Permalink
Fix the regex start
Browse files Browse the repository at this point in the history
Fixes #243 and #3
  • Loading branch information
sheetalkamat committed Sep 9, 2016
1 parent c1c0c65 commit cfd2afb
Show file tree
Hide file tree
Showing 8 changed files with 2,459 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ repository:

regex:
name: string.regex.ts
begin: (?<=[=(:,\[?+!]|^|return|=>|&&|\|\|)\s*(/)(?![/*+{}?])(?=.*/)
begin: (?<=[=(:,\[?+!]|^|return|case|=>|&&|\|\||\*\/)\s*(/)(?![/*+{}?])(?=.*/)
beginCaptures:
'1': {name: punctuation.definition.string.begin.ts}
end: (/)([gimuy]*)
Expand Down
2 changes: 1 addition & 1 deletion TypeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,7 @@
<key>regex</key>
<dict>
<key>begin</key>
<string>(?&lt;=[=(:,\[?+!]|^|return|=&gt;|&amp;&amp;|\|\|)\s*(/)(?![/*+{}?])(?=.*/)</string>
<string>(?&lt;=[=(:,\[?+!]|^|return|case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(/)(?![/*+{}?])(?=.*/)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down
2 changes: 1 addition & 1 deletion TypeScriptReact.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ repository:

regex:
name: string.regex.tsx
begin: (?<=[=(:,\[?+!]|^|return|=>|&&|\|\|)\s*(/)(?![/*+{}?])(?=.*/)
begin: (?<=[=(:,\[?+!]|^|return|case|=>|&&|\|\||\*\/)\s*(/)(?![/*+{}?])(?=.*/)
beginCaptures:
'1': {name: punctuation.definition.string.begin.tsx}
end: (/)([gimuy]*)
Expand Down
2 changes: 1 addition & 1 deletion TypeScriptReact.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -3184,7 +3184,7 @@
<key>regex</key>
<dict>
<key>begin</key>
<string>(?&lt;=[=(:,\[?+!]|^|return|=&gt;|&amp;&amp;|\|\|)\s*(/)(?![/*+{}?])(?=.*/)</string>
<string>(?&lt;=[=(:,\[?+!]|^|return|case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(/)(?![/*+{}?])(?=.*/)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down
2,314 changes: 2,314 additions & 0 deletions tests/baselines/Issue243.baseline.txt

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions tests/baselines/Issue3.baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
original file
-----------------------------------
let regex = /**/ /foo/;
-----------------------------------

>let regex = /**/ /foo/;
^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.assignment.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts comment.block.ts punctuation.definition.comment.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts comment.block.ts punctuation.definition.comment.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.regex.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.regex.ts punctuation.definition.string.begin.ts
^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.regex.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.regex.ts punctuation.definition.string.end.ts
^^
source.ts
108 changes: 108 additions & 0 deletions tests/cases/Issue243.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
'use strict';

var pieces = [];
var numeration = [];

for (var i in pieces) {
switch (true) {
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
case /^\"?Accession\"?/.test(pieces[i]):
numeration[0] = i;
break;
}
}
1 change: 1 addition & 0 deletions tests/cases/Issue3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let regex = /**/ /foo/;

0 comments on commit cfd2afb

Please sign in to comment.