1 refactor(vscode-extension): allow toggle attributes via LS. · angular/angular@614dd58 · GitHub
Skip to content

Commit 614dd58

Browse files
committed
refactor(vscode-extension): allow toggle attributes via LS.
This change allows to toggle attributes that are on their own line and have a 1+ leading space. This change doesn't suffer from the issue that was reverted in #68067.
1 parent e95d846 commit 614dd58

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

vscode-ng-language-service/syntaxes/src/template-tag.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ export const TemplateTag: GrammarDefinition = {
1313
injectionSelector: 'L:text.html#meta.tag -comment',
1414
patterns: [
1515
{include: '#inlineComments'},
16+
{include: '#leadingSpace'},
1617
{include: '#twoWayBinding'},
1718
{include: '#propertyBinding'},
1819
{include: '#eventBinding'},
1920
{include: '#templateBinding'},
2021
{include: '#standardAttribute'},
2122
],
2223
repository: {
24+
leadingSpace: {
25+
match: /^\s+/,
26+
name: 'template.tag.ng',
27+
},
2328
standardAttribute: {
2429
begin: /([-_a-zA-Z0-9.$:]+)(=)(["'])/,
2530
beginCaptures: {

vscode-ng-language-service/syntaxes/template-tag.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
{
66
"include": "#inlineComments"
77
},
8+
{
9+
"include": "#leadingSpace"
10+
},
811
{
912
"include": "#twoWayBinding"
1013
},
@@ -22,6 +25,10 @@
2225
}
2326
],
2427
"repository": {
28+
"leadingSpace": {
29+
"match": "^\\s+",
30+
"name": "template.tag.ng"
31+
},
2532
"standardAttribute": {
2633
"begin": "([-_a-zA-Z0-9.$:]+)(=)([\"'])",
2734
"beginCaptures": {

vscode-ng-language-service/syntaxes/test/data/template-tag.html.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,23 +801,23 @@
801801
><div
802802
#^^^^^ template.tag.ng
803803
> // comment 0
804-
#^^ template.tag.ng
804+
#^^ template.tag.ng template.tag.ng
805805
# ^^ template.tag.ng comment.line.double-slash.ts punctuation.definition.comment.ts
806806
# ^^^^^^^^^^ template.tag.ng comment.line.double-slash.ts
807807
> /* comment 1 */
808-
#^^ template.tag.ng
808+
#^^ template.tag.ng template.tag.ng
809809
# ^^ template.tag.ng comment.block.ts punctuation.definition.comment.ts
810810
# ^^^^^^^^^^^ template.tag.ng comment.block.ts
811811
# ^^ template.tag.ng comment.block.ts punctuation.definition.comment.ts
812812
> attr1="value1"
813-
#^^ template.tag.ng
813+
#^^ template.tag.ng template.tag.ng
814814
# ^^^^^ template.tag.ng meta.attribute.standard.html entity.other.attribute-name.html
815815
# ^ template.tag.ng meta.attribute.standard.html punctuation.separator.key-value.html
816816
# ^ template.tag.ng meta.attribute.standard.html string.quoted.html punctuation.definition.string.begin.html
817817
# ^^^^^^ template.tag.ng meta.attribute.standard.html variable.other.readwrite.ts
818818
# ^ template.tag.ng meta.attribute.standard.html string.quoted.html punctuation.definition.string.end.html
819819
> /*
820-
#^^ template.tag.ng
820+
#^^ template.tag.ng template.tag.ng
821821
# ^^ template.tag.ng comment.block.ts punctuation.definition.comment.ts
822822
> comment 2
823823
#^^^^^^^^^^^^^^^ template.tag.ng comment.block.ts
@@ -827,7 +827,7 @@
827827
#^^ template.tag.ng comment.block.ts
828828
# ^^ template.tag.ng comment.block.ts punctuation.definition.comment.ts
829829
> attr2="value2"
830-
#^^ template.tag.ng
830+
#^^ template.tag.ng template.tag.ng
831831
# ^^^^^ template.tag.ng meta.attribute.standard.html entity.other.attribute-name.html
832832
# ^ template.tag.ng meta.attribute.standard.html punctuation.separator.key-value.html
833833
# ^ template.tag.ng meta.attribute.standard.html string.quoted.html punctuation.definition.string.begin.html

0 commit comments

Comments
 (0)