Skip to content

Commit ea59fd1

Browse files
committed
Fix the regex for tag detection to handle ternary operator
Fixes #357
1 parent b5ce6b5 commit ea59fd1

File tree

4 files changed

+425
-2
lines changed

4 files changed

+425
-2
lines changed

TypeScriptReact.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ repository:
112112
# We need to differentiate between the relational '<' operator and the beginning of a tag using the surrounding context.
113113
begin: >-
114114
(?x)
115-
(?<=[({\[,?=>]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
115+
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
116116
(?!(<)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)) #look ahead is not start of tag without attributes
117117
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
118118
(?=(<)\s*

TypeScriptReact.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5652,7 +5652,7 @@
56525652
<dict>
56535653
<key>begin</key>
56545654
<string>(?x)
5655-
(?&lt;=[({\[,?=&gt;]|&amp;&amp;|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
5655+
(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
56565656
(?!(&lt;)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)) #look ahead is not start of tag without attributes
56575657
(?!&lt;\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=&gt;])|,)) # look ahead is not type parameter of arrow
56585658
(?=(&lt;)\s*

0 commit comments

Comments
 (0)