Skip to content

Commit 7d04bb6

Browse files
committed
fix: Correct syntax highlighting for style.prop.% (#1622)
The previous syntax regex capture did not allow a % symbol at all. This commit updates the regex to allow the property binding and binding name to be terminated by 0 or 1 '%' characters. Fixes #1619 (cherry picked from commit 3848142)
1 parent 45b1d7e commit 7d04bb6

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

syntaxes/src/template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const Template: GrammarDefinition = {
3636
},
3737

3838
propertyBinding: {
39-
begin: /(\[\s*@?[-_a-zA-Z0-9.$]*\s*])(=)(["'])/,
39+
begin: /(\[\s*@?[-_a-zA-Z0-9.$]*%?\s*])(=)(["'])/,
4040
beginCaptures: {
4141
1: {
4242
name: 'entity.other.attribute-name.html entity.other.ng-binding-name.property.html',
@@ -130,7 +130,7 @@ export const Template: GrammarDefinition = {
130130
bindingKey: {
131131
patterns: [
132132
{
133-
match: /([\[\(]{1,2}|\*)(?:\s*)(@?[-_a-zA-Z0-9.$]*)(?:\s*)([\]\)]{1,2})?/,
133+
match: /([\[\(]{1,2}|\*)(?:\s*)(@?[-_a-zA-Z0-9.$]*%?)(?:\s*)([\]\)]{1,2})?/,
134134
captures: {
135135
1: {name: 'punctuation.definition.ng-binding-name.begin.html'},
136136
2: {

syntaxes/template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
]
4141
},
4242
"propertyBinding": {
43-
"begin": "(\\[\\s*@?[-_a-zA-Z0-9.$]*\\s*])(=)([\"'])",
43+
"begin": "(\\[\\s*@?[-_a-zA-Z0-9.$]*%?\\s*])(=)([\"'])",
4444
"beginCaptures": {
4545
"1": {
4646
"name": "entity.other.attribute-name.html entity.other.ng-binding-name.property.html",
@@ -170,7 +170,7 @@
170170
"bindingKey": {
171171
"patterns": [
172172
{
173-
"match": "([\\[\\(]{1,2}|\\*)(?:\\s*)(@?[-_a-zA-Z0-9.$]*)(?:\\s*)([\\]\\)]{1,2})?",
173+
"match": "([\\[\\(]{1,2}|\\*)(?:\\s*)(@?[-_a-zA-Z0-9.$]*%?)(?:\\s*)([\\]\\)]{1,2})?",
174174
"captures": {
175175
"1": {
176176
"name": "punctuation.definition.ng-binding-name.begin.html"

syntaxes/test/data/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'class-two',
99
'class-three'
1010
]"></div>
11+
<div [style.right.%]="val"></div>
1112
<div [@animation.trigger]="val"></div>
1213
<img [attr.aria-label]="val" />
1314
<div [my-property]="val"></div>

syntaxes/test/data/template.html.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@
7777
#^ template.ng meta.ng-binding.property.html expression.ng meta.array.literal.ts meta.brace.square.ts
7878
# ^ template.ng meta.ng-binding.property.html string.quoted.html punctuation.definition.string.end.html
7979
# ^^^^^^^^ template.ng
80+
><div [style.right.%]="val"></div>
81+
#^^^^^ template.ng
82+
# ^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html punctuation.definition.ng-binding-name.begin.html
83+
# ^^^^^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html entity.other.ng-binding-name.style.right.%.html
84+
# ^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html entity.other.ng-binding-name.style.right.%.html punctuation.accessor.html
85+
# ^^^^^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html entity.other.ng-binding-name.style.right.%.html
86+
# ^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html entity.other.ng-binding-name.style.right.%.html punctuation.accessor.html
87+
# ^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html entity.other.ng-binding-name.style.right.%.html
88+
# ^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html punctuation.definition.ng-binding-name.end.html
89+
# ^ template.ng meta.ng-binding.property.html punctuation.separator.key-value.html
90+
# ^ template.ng meta.ng-binding.property.html string.quoted.html punctuation.definition.string.begin.html
91+
# ^^^ template.ng meta.ng-binding.property.html expression.ng variable.other.readwrite.ts
92+
# ^ template.ng meta.ng-binding.property.html string.quoted.html punctuation.definition.string.end.html
93+
# ^^^^^^^^ template.ng
8094
><div [@animation.trigger]="val"></div>
8195
#^^^^^ template.ng
8296
# ^ template.ng meta.ng-binding.property.html entity.other.attribute-name.html entity.other.ng-binding-name.property.html punctuation.definition.ng-binding-name.begin.html

0 commit comments

Comments
 (0)