diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage
index d3c99d9e..7037986a 100644
--- a/TypeScript.YAML-tmLanguage
+++ b/TypeScript.YAML-tmLanguage
@@ -26,11 +26,45 @@ repository:
'1': { name: variable.ts }
end: (?=$|[;,])
patterns:
+ - include: '#ternary-expression'
- include: '#type-annotation'
- include: '#string'
- include: '#comment'
- include: '#expression'
+ ternary-expression:
+ begin: (?=\?)
+ end: (?=$|[;,])
+ patterns:
+ - include: '#ternary-operator'
+ - include: '#ternary-expression-type'
+
+ ternary-operator:
+ begin: (\?)
+ end: (:)
+ patterns:
+ - include: '#ternary-expression-type'
+
+ ternary-expression-type:
+ name: meta.expression.ts
+ patterns:
+ - include: '#string'
+ - include: '#regex'
+ - include: '#template'
+ - include: '#comment'
+ - include: '#literal'
+ - include: '#paren-expression'
+ - include: '#ternary-expression'
+ - include: '#import-operator'
+ - include: '#expression-operator'
+ - include: '#imply-operator'
+ - include: '#relational-operator'
+ - include: '#arithmetic-operator'
+ - include: '#logic-operator'
+ - include: '#assignment-operator'
+ - include: '#type-primitive'
+ - include: '#function-call'
+
control-statement:
name: keyword.control.ts
match: (?
+ ternary-expression
+
+ begin
+ (?=\?)
+ end
+ (?=$|[;,])
+ patterns
+
+
+ include
+ #ternary-operator
+
+
+ include
+ #ternary-expression-type
+
+
+
+ ternary-expression-type
+
+ name
+ meta.expression.ts
+ patterns
+
+
+ include
+ #string
+
+
+ include
+ #regex
+
+
+ include
+ #template
+
+
+ include
+ #comment
+
+
+ include
+ #literal
+
+
+ include
+ #paren-expression
+
+
+ include
+ #ternary-expression
+
+
+ include
+ #import-operator
+
+
+ include
+ #expression-operator
+
+
+ include
+ #imply-operator
+
+
+ include
+ #relational-operator
+
+
+ include
+ #arithmetic-operator
+
+
+ include
+ #logic-operator
+
+
+ include
+ #assignment-operator
+
+
+ include
+ #type-primitive
+
+
+ include
+ #function-call
+
+
+
+ ternary-operator
+
+ begin
+ (\?)
+ end
+ (:)
+ patterns
+
+
+ include
+ #ternary-expression-type
+
+
+
this-literal
match
@@ -1839,6 +1943,10 @@
meta.var-single-variable.expr.ts
patterns
+
+ include
+ #ternary-expression
+
include
#type-annotation
diff --git a/TypeScriptReact.YAML-tmLanguage b/TypeScriptReact.YAML-tmLanguage
index f95a2ac4..5f3ef296 100644
--- a/TypeScriptReact.YAML-tmLanguage
+++ b/TypeScriptReact.YAML-tmLanguage
@@ -28,11 +28,45 @@ repository:
'1': { name: variable.tsx }
end: (?=$|[;,])
patterns:
+ - include: '#ternary-expression'
- include: '#type-annotation'
- include: '#string'
- include: '#comment'
- include: '#expression'
+ ternary-expression:
+ begin: (?=\?)
+ end: (?=$|[;,])
+ patterns:
+ - include: '#ternary-operator'
+ - include: '#ternary-expression-type'
+
+ ternary-operator:
+ begin: (\?)
+ end: (:)
+ patterns:
+ - include: '#ternary-expression-type'
+
+ ternary-expression-type:
+ name: meta.expression.tsx
+ patterns:
+ - include: '#string'
+ - include: '#regex'
+ - include: '#template'
+ - include: '#comment'
+ - include: '#literal'
+ - include: '#paren-expression'
+ - include: '#ternary-expression'
+ - include: '#import-operator'
+ - include: '#expression-operator'
+ - include: '#imply-operator'
+ - include: '#relational-operator'
+ - include: '#arithmetic-operator'
+ - include: '#logic-operator'
+ - include: '#assignment-operator'
+ - include: '#type-primitive'
+ - include: '#function-call'
+
control-statement:
name: keyword.control.tsx
match: (?
+ ternary-expression
+
+ begin
+ (?=\?)
+ end
+ (?=$|[;,])
+ patterns
+
+
+ include
+ #ternary-operator
+
+
+ include
+ #ternary-expression-type
+
+
+
+ ternary-expression-type
+
+ name
+ meta.expression.tsx
+ patterns
+
+
+ include
+ #string
+
+
+ include
+ #regex
+
+
+ include
+ #template
+
+
+ include
+ #comment
+
+
+ include
+ #literal
+
+
+ include
+ #paren-expression
+
+
+ include
+ #ternary-expression
+
+
+ include
+ #import-operator
+
+
+ include
+ #expression-operator
+
+
+ include
+ #imply-operator
+
+
+ include
+ #relational-operator
+
+
+ include
+ #arithmetic-operator
+
+
+ include
+ #logic-operator
+
+
+ include
+ #assignment-operator
+
+
+ include
+ #type-primitive
+
+
+ include
+ #function-call
+
+
+
+ ternary-operator
+
+ begin
+ (\?)
+ end
+ (:)
+ patterns
+
+
+ include
+ #ternary-expression-type
+
+
+
this-literal
match
@@ -2205,6 +2309,10 @@
meta.var-single-variable.expr.tsx
patterns
+
+ include
+ #ternary-expression
+
include
#type-annotation
diff --git a/tests/baselines/Issue124.txt b/tests/baselines/Issue124.txt
new file mode 100644
index 00000000..e01630c5
--- /dev/null
+++ b/tests/baselines/Issue124.txt
@@ -0,0 +1,27 @@
+[6, 9]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts constant.language.boolean.ts
+[6, 16]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts constant.language.boolean.ts
+[6, 23]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts constant.language.boolean.ts
+[7, 9]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts constant.language.boolean.ts
+[7, 16]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts constant.language.boolean.ts
+[7, 23]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.template.ts string.template.ts
+[7, 24]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.template.ts string.template.ts
+[7, 32]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.template.ts template.element.ts keyword.others.ts
+[8, 9]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts constant.language.boolean.ts
+[8, 16]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.template.ts string.template.ts
+[8, 17]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.template.ts string.template.ts
+[8, 26]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.template.ts string.template.ts
+[8, 27]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.template.ts string.template.ts
+[10, 5]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.ts
+[10, 14]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
+[10, 16]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
+[10, 18]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.brace.paren.ts
+[10, 35]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts constant.language.boolean.ts
+[12, 5]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.ts
+[12, 15]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
+[12, 20]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.comparison.ts
+[12, 24]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.single.ts
+[12, 30]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
+[12, 32]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.single.ts
+[12, 40]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
+[12, 42]: source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.single.ts
+[15, 2]: source.ts comment.block.ts
\ No newline at end of file
diff --git a/tests/cases/Issue124.ts b/tests/cases/Issue124.ts
new file mode 100644
index 00000000..d685a988
--- /dev/null
+++ b/tests/cases/Issue124.ts
@@ -0,0 +1,16 @@
+/*
+ Solving Issue #124, #80, #81
+ Adding capability of ternary strings.
+*/
+
+let a = ^^true ? ^^true : ^^true;
+let b = ^^true ? ^^true : ^^`^^this is ^^${} highlighted`
+let c = ^^true ? ^^`^^hello` : ^^`^^this ${DEPENDENCY_SEPARATOR}${moduleName} is highlighted`;
+
+var ^^newVar = ^^a ^^? ^^(b == `hello`) : ^^true;
+
+var ^^debArch = ^^arch ^^=== ^^'x64' ^^? ^^'amd64' ^^: ^^'i386';
+
+/*
+ ^^Comment
+*/
\ No newline at end of file