From 67693f1ba3a98aff62f199160c8e4b9fba3e12cf Mon Sep 17 00:00:00 2001 From: RedCMD <33529441+RedCMD@users.noreply.github.com> Date: Tue, 13 Feb 2024 18:27:08 +1300 Subject: [PATCH 1/6] Make `regex` lookahead check more strict --- TypeScript.YAML-tmLanguage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage index 7a61c3df..ea7b4f32 100644 --- a/TypeScript.YAML-tmLanguage +++ b/TypeScript.YAML-tmLanguage @@ -140,7 +140,7 @@ variables: {{functionLikeType}} | (:\s*(=>|{{matchingParenthesis}}|(<[^<>]*>)|[^<>(),=])+={{functionOrArrowLookup}}) arrowFunctionEnd: (?==>|\{|(^\s*(export|function|class|interface|let|var|{{usingKeyword}}|{{awaitUsingKeyword}}|const|import|enum|namespace|module|type|abstract|declare)\s+)) - regexpTail: ([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]) + regexpTail: (?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$]) completeRegexp: \/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/{{regexpTail}}) patterns: From 2d31dd7b711b22c979534de4d54b479001497a0d Mon Sep 17 00:00:00 2001 From: RedCMD <33529441+RedCMD@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:14:15 +1300 Subject: [PATCH 2/6] Add `Issue1024.ts` test file --- tests/cases/Issue1024.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/cases/Issue1024.ts diff --git a/tests/cases/Issue1024.ts b/tests/cases/Issue1024.ts new file mode 100644 index 00000000..820f819e --- /dev/null +++ b/tests/cases/Issue1024.ts @@ -0,0 +1,2 @@ +1 + / f(/u/g); From 278f8dd06075b34885f68570c190a87a4557d2f3 Mon Sep 17 00:00:00 2001 From: RedCMD <33529441+RedCMD@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:23:01 +1300 Subject: [PATCH 3/6] Add `Issue1024.baseline.txt` test file --- tests/baselines/Issue1024.baseline.txt | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/baselines/Issue1024.baseline.txt diff --git a/tests/baselines/Issue1024.baseline.txt b/tests/baselines/Issue1024.baseline.txt new file mode 100644 index 00000000..aa220d42 --- /dev/null +++ b/tests/baselines/Issue1024.baseline.txt @@ -0,0 +1,34 @@ +original file +----------------------------------- +1 + / f(/u/g); +----------------------------------- + +Grammar: TypeScript.tmLanguage +----------------------------------- +>1 + ^ + source.ts constant.numeric.decimal.ts +> / f(/u/g); + ^ + source.ts + ^ + source.ts keyword.operator.arithmetic.ts + ^ + source.ts + ^ + source.ts meta.function-call.ts entity.name.function.ts + ^ + source.ts meta.brace.round.ts + ^ + source.ts string.regexp.ts punctuation.definition.string.begin.ts + ^ + source.ts string.regexp.ts + ^ + source.ts string.regexp.ts punctuation.definition.string.end.ts + ^ + source.ts string.regexp.ts keyword.other.ts + ^ + source.ts meta.brace.round.t + ^ + source.ts punctuation.terminator.statement.ts From 55678f526623cbcd6ecd8aa40f0daeb28bbc68c0 Mon Sep 17 00:00:00 2001 From: RedCMD Date: Fri, 25 Oct 2024 16:17:14 +1300 Subject: [PATCH 4/6] Update `.tmLanguage` files --- TypeScript.tmLanguage | 6 +++--- TypeScriptReact.tmLanguage | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TypeScript.tmLanguage b/TypeScript.tmLanguage index 1a3f668b..87e1dfa7 100644 --- a/TypeScript.tmLanguage +++ b/TypeScript.tmLanguage @@ -4365,7 +4365,7 @@ name string.regexp.ts begin - (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 @@ -8470,7 +8470,7 @@ name string.regexp.ts begin - (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 1 @@ -8506,7 +8506,7 @@ name string.regexp.ts begin - ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage index dcdd118b..d6677023 100644 --- a/TypeScriptReact.tmLanguage +++ b/TypeScriptReact.tmLanguage @@ -4387,7 +4387,7 @@ name string.regexp.tsx begin - (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 @@ -8418,7 +8418,7 @@ name string.regexp.tsx begin - (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 1 @@ -8454,7 +8454,7 @@ name string.regexp.tsx begin - ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 From 443dafcb326fd6bfbaf367dd137afb21d1d39e3d Mon Sep 17 00:00:00 2001 From: RedCMD Date: Fri, 25 Oct 2024 16:27:18 +1300 Subject: [PATCH 5/6] Fix `Issue1024` test --- tests/baselines/Issue1024.baseline.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/baselines/Issue1024.baseline.txt b/tests/baselines/Issue1024.baseline.txt index aa220d42..ae5b5788 100644 --- a/tests/baselines/Issue1024.baseline.txt +++ b/tests/baselines/Issue1024.baseline.txt @@ -2,6 +2,7 @@ original file ----------------------------------- 1 / f(/u/g); + ----------------------------------- Grammar: TypeScript.tmLanguage @@ -29,6 +30,9 @@ Grammar: TypeScript.tmLanguage ^ source.ts string.regexp.ts keyword.other.ts ^ - source.ts meta.brace.round.t + source.ts meta.brace.round.ts ^ source.ts punctuation.terminator.statement.ts +> + ^ + source.ts \ No newline at end of file From 955f5a34e74e4223f9af93fbc7d84ce3d339a262 Mon Sep 17 00:00:00 2001 From: RedCMD Date: Fri, 25 Oct 2024 16:39:48 +1300 Subject: [PATCH 6/6] Merge #1032 --- TypeScript.YAML-tmLanguage | 8 ++++---- TypeScript.tmLanguage | 12 ++++++------ TypeScriptReact.tmLanguage | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage index ea7b4f32..1489e899 100644 --- a/TypeScript.YAML-tmLanguage +++ b/TypeScript.YAML-tmLanguage @@ -140,7 +140,7 @@ variables: {{functionLikeType}} | (:\s*(=>|{{matchingParenthesis}}|(<[^<>]*>)|[^<>(),=])+={{functionOrArrowLookup}}) arrowFunctionEnd: (?==>|\{|(^\s*(export|function|class|interface|let|var|{{usingKeyword}}|{{awaitUsingKeyword}}|const|import|enum|namespace|module|type|abstract|declare)\s+)) - regexpTail: (?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$]) + regexpTail: (?!\*)[dgimsuvy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$]) completeRegexp: \/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/{{regexpTail}}) patterns: @@ -1365,7 +1365,7 @@ repository: begin: (?<=\))\s*{{completeRegexp}} beginCaptures: '0': { name: punctuation.definition.string.begin.ts } - end: (/)([dgimsuy]*) + end: (/)([dgimsuvy]*) endCaptures: '1': { name: punctuation.definition.string.end.ts } '2': { name: keyword.other.ts } @@ -2793,7 +2793,7 @@ repository: begin: (?|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/{{regexpTail}}) beginCaptures: '1': { name: punctuation.definition.string.begin.ts } - end: (/)([dgimsuy]*) + end: (/)([dgimsuvy]*) endCaptures: '1': { name: punctuation.definition.string.end.ts } '2': { name: keyword.other.ts} @@ -2804,7 +2804,7 @@ repository: begin: ((?name string.regexp.ts begin - (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuvy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 @@ -4375,7 +4375,7 @@ end - (/)([dgimsuy]*) + (/)([dgimsuvy]*) endCaptures 1 @@ -8470,7 +8470,7 @@ name string.regexp.ts begin - (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/(?!\*)[dgimsuvy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 1 @@ -8480,7 +8480,7 @@ end - (/)([dgimsuy]*) + (/)([dgimsuvy]*) endCaptures 1 @@ -8506,7 +8506,7 @@ name string.regexp.ts begin - ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuvy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 @@ -8516,7 +8516,7 @@ end - (/)([dgimsuy]*) + (/)([dgimsuvy]*) endCaptures 1 diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage index d6677023..718d5ddf 100644 --- a/TypeScriptReact.tmLanguage +++ b/TypeScriptReact.tmLanguage @@ -4387,7 +4387,7 @@ name string.regexp.tsx begin - (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuvy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 @@ -4397,7 +4397,7 @@ end - (/)([dgimsuy]*) + (/)([dgimsuvy]*) endCaptures 1 @@ -8418,7 +8418,7 @@ name string.regexp.tsx begin - (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + (?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/(?!\*)[dgimsuvy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 1 @@ -8428,7 +8428,7 @@ end - (/)([dgimsuy]*) + (/)([dgimsuvy]*) endCaptures 1 @@ -8454,7 +8454,7 @@ name string.regexp.tsx begin - ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) + ((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/(?!\*)[dgimsuvy]*((?!\/)|(?=\/\*))(?!\s*[a-zA-Z0-9_$])) beginCaptures 0 @@ -8464,7 +8464,7 @@ end - (/)([dgimsuy]*) + (/)([dgimsuvy]*) endCaptures 1