Fix the regexp tail to account for // and /* both

Fixes #787
This commit is contained in:
Sheetal Nandi 2019-11-07 08:57:02 -08:00
Родитель d7f4846793
Коммит 4daff7b890
5 изменённых файлов: 52 добавлений и 7 удалений

Просмотреть файл

@ -127,7 +127,7 @@ variables:
{{functionLikeType}} |
(:\s*(=>|{{matchingParenthesis}}|(<[^<>]*>)|[^<>(),=])+={{functionOrArrowLookup}})
arrowFunctionEnd: (?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))
regexpTail: ([gimsuy]+|(?!\*))(?!\s*[a-zA-Z0-9_$])
regexpTail: ([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])
completeRegexp: \/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/{{regexpTail}})
patterns:

Просмотреть файл

@ -4081,7 +4081,7 @@
<key>name</key>
<string>string.regexp.ts</string>
<key>begin</key>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?!\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
@ -7844,7 +7844,7 @@
<key>name</key>
<string>string.regexp.ts</string>
<key>begin</key>
<string>(?&lt;!\+\+|--|})(?&lt;=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?!\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;!\+\+|--|})(?&lt;=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -7880,7 +7880,7 @@
<key>name</key>
<string>string.regexp.ts</string>
<key>begin</key>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?!\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>

Просмотреть файл

@ -4103,7 +4103,7 @@
<key>name</key>
<string>string.regexp.tsx</string>
<key>begin</key>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?!\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
@ -7792,7 +7792,7 @@
<key>name</key>
<string>string.regexp.tsx</string>
<key>begin</key>
<string>(?&lt;!\+\+|--|})(?&lt;=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?!\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;!\+\+|--|})(?&lt;=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -7828,7 +7828,7 @@
<key>name</key>
<string>string.regexp.tsx</string>
<key>begin</key>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?!\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>

Просмотреть файл

@ -0,0 +1,44 @@
original file
-----------------------------------
console.log("4" / "2"); // 2
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>console.log("4" / "2"); // 2
^^^^^^^
source.ts meta.function-call.ts support.class.console.ts
^
source.ts meta.function-call.ts punctuation.accessor.ts
^^^
source.ts meta.function-call.ts support.function.console.ts
^
source.ts meta.brace.round.ts
^
source.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts string.quoted.double.ts
^
source.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts
^
source.ts keyword.operator.arithmetic.ts
^
source.ts
^
source.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts string.quoted.double.ts
^
source.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.brace.round.ts
^
source.ts punctuation.terminator.statement.ts
^
source.ts
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^
source.ts comment.line.double-slash.ts

1
tests/cases/Issue787.ts Normal file
Просмотреть файл

@ -0,0 +1 @@
console.log("4" / "2"); // 2