From 6d6a5bddf009dc7683f5f7be5c303e944962e28f Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 18 Jun 2024 18:45:54 +0200 Subject: [PATCH] Add support for regexp v flag --- TypeScript.YAML-tmLanguage | 8 +++--- TypeScript.tmLanguage | 12 ++++----- TypeScriptReact.tmLanguage | 12 ++++----- tests/baselines/Issue1006.baseline.txt | 36 ++++++++++++++++++++++++++ tests/cases/Issue1006.ts | 1 + 5 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 tests/baselines/Issue1006.baseline.txt create mode 100644 tests/cases/Issue1006.ts diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage index 7a61c3df..3378899d 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 dcdd118b..77533783 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 diff --git a/tests/baselines/Issue1006.baseline.txt b/tests/baselines/Issue1006.baseline.txt new file mode 100644 index 00000000..1ca57dfc --- /dev/null +++ b/tests/baselines/Issue1006.baseline.txt @@ -0,0 +1,36 @@ +original file +----------------------------------- +const a = /.*/v; + +----------------------------------- + +Grammar: TypeScript.tmLanguage +----------------------------------- +>const a = /.*/v; + ^^^^^ + 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 meta.definition.variable.ts variable.other.constant.ts + ^ + source.ts meta.var.expr.ts meta.var-single-variable.expr.ts + ^ + source.ts meta.var.expr.ts keyword.operator.assignment.ts + ^ + source.ts meta.var.expr.ts string.regexp.ts + ^ + source.ts meta.var.expr.ts string.regexp.ts punctuation.definition.string.begin.ts + ^ + source.ts meta.var.expr.ts string.regexp.ts constant.other.character-class.regexp + ^ + source.ts meta.var.expr.ts string.regexp.ts keyword.operator.quantifier.regexp + ^ + source.ts meta.var.expr.ts string.regexp.ts punctuation.definition.string.end.ts + ^ + source.ts meta.var.expr.ts string.regexp.ts keyword.other.ts + ^ + source.ts punctuation.terminator.statement.ts +> + ^ + source.ts \ No newline at end of file diff --git a/tests/cases/Issue1006.ts b/tests/cases/Issue1006.ts new file mode 100644 index 00000000..e8ac531f --- /dev/null +++ b/tests/cases/Issue1006.ts @@ -0,0 +1 @@ +const a = /.*/v;