File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 563
563
"match" : " \\\\ (x\\ h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)"
564
564
},
565
565
"ternaryExpression" : {
566
- "begin" : " (?!\\ ?\\ .\\ s*[^[:digit:]])(\\ ?)(?! \\ ?) " ,
566
+ "begin" : " (?!\\ ?\\ .\\ s*[^[:digit:]])(\\ ?)" ,
567
567
"beginCaptures" : {
568
568
"1" : {
569
569
"name" : " keyword.operator.ternary.ts"
Original file line number Diff line number Diff line change @@ -593,8 +593,12 @@ export const Expression: GrammarDefinition = {
593
593
match : / \\ ( x \h { 2 } | [ 0 - 2 ] [ 0 - 7 ] { 0 , 2 } | 3 [ 0 - 6 ] [ 0 - 7 ] ? | 3 7 [ 0 - 7 ] ? | [ 4 - 7 ] [ 0 - 7 ] ? | .| $ ) / ,
594
594
} ,
595
595
596
+ // Derived from
597
+ // https://github.com/sheetalkamat/TypeScript-TmLanguage-VsCode/blob/04219109f3e2090f787c0fa8743e73a4bd1ad876/syntaxes/TypeScript.tmLanguage.json#L2830-L2848
596
598
ternaryExpression : {
597
- begin : / (? ! \? \. \s * [ ^ [: digit :] ] ) ( \? ) (? ! \? ) / ,
599
+ // 1. negative lookahead (?!\?\.\s*[^[:digit:]]) ensures safe navigation does not match
600
+ // 2. match the ternary question mark with (\?)
601
+ begin : / (? ! \? \. \s * [ ^ [: digit :] ] ) ( \? ) / ,
598
602
beginCaptures : {
599
603
1 : {
600
604
name : 'keyword.operator.ternary.ts' ,
Original file line number Diff line number Diff line change 71
71
{{ condition ? 'test' : "test" }}
72
72
{{ condition ? [function(), variable] : {} }}
73
73
{{ condition ? condition2 ? condition3 ? 1 : 2 : 3 : 4 }}
74
+ <!-- Don't match safe navigations -->
75
+ {{ condition?.a : 1 }}
74
76
75
77
<!-- Microsyntax -->
76
78
<!-- Let Expression -->
Original file line number Diff line number Diff line change 825
825
# ^ template .ng expression .ng constant .numeric .decimal .ts
826
826
# ^ template .ng expression .ng
827
827
# ^^ template .ng punctuation .definition .block .ts
828
+ >< ! -- Don ' t match safe navigations -->
829
+ #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ template .ng
830
+ > {{ condition?.a : 1 }}
831
+ #^^ template .ng punctuation .definition .block .ts
832
+ # ^ template .ng expression .ng
833
+ # ^^^^^^^^^ template .ng expression .ng variable .other .readwrite .ts
834
+ # ^^ template .ng expression .ng punctuation .accessor .ts
835
+ # ^ template .ng expression .ng variable .other .property .ts
836
+ # ^^^ template .ng expression .ng
837
+ # ^ template .ng expression .ng constant .numeric .decimal .ts
838
+ # ^ template .ng expression .ng
839
+ # ^^ template .ng punctuation .definition .block .ts
828
840
>
829
841
>< ! -- Microsyntax -- >
830
842
#^^^^^^^^^^^^^^^^^^^^^ template .ng
You can’t perform that action at this time.
0 commit comments