Skip to content

Commit

Permalink
fix(syntaxes): add back block syntaxes to injection for entire TS file
Browse files Browse the repository at this point in the history
We rely on the `injectionSelector` to prevent matching our grammars in
contexts which they should not apply. The `injectionSelector` only applies
when the grammar is injected to the file via `injectTo`. Otherwise, the
grammer is applied directly when it is included in the `patterns` array
of another match.

fixes angular#2062
  • Loading branch information
atscott committed Jul 10, 2024
1 parent f4a258c commit 4a204ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,17 @@
{
"path": "./syntaxes/template.json",
"scopeName": "template.ng",
"injectTo": ["text.html.derivative"]
"injectTo": ["text.html.derivative", "source.ts"]
},
{
"path": "./syntaxes/template-blocks.json",
"scopeName": "template.blocks.ng",
"injectTo": ["text.html.derivative"]
"injectTo": ["text.html.derivative", "source.ts"]
},
{
"path": "./syntaxes/let-declaration.json",
"scopeName": "template.let.ng",
"injectTo": ["text.html.derivative"]
"injectTo": ["text.html.derivative", "source.ts"]
},
{
"path": "./syntaxes/template-tag.json",
Expand Down
6 changes: 0 additions & 6 deletions syntaxes/inline-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@
},
{
"include": "template.ng"
},
{
"include": "template.blocks.ng"
},
{
"include": "template.let.ng"
}
]
}
Expand Down
10 changes: 2 additions & 8 deletions syntaxes/src/inline-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ export const InlineTemplate: GrammarDefinition = {
endCaptures: {0: {name: 'string'}},
contentName: 'text.html.derivative',
patterns: [
{include: 'text.html.derivative'}, {include: 'template.ng'},
{include: 'template.blocks.ng'}, {include: 'template.let.ng'},
// note: template.tag.ng isn't used here and needs to be directly injected into source.ts
// scopes at the top level because it relies entirely on the injectionSelector to filter its
// matching out of non-html tag contexts. Since we don't have any scopes that match HTML
// tags, we rely entirely on the text.html.derivative pattern matching and apply the tag
// scope via injectionSelector only rather than being able to include it in a pattern list
// of another match.
{include: 'text.html.derivative'},
{include: 'template.ng'},
]
}
}
Expand Down

0 comments on commit 4a204ca

Please sign in to comment.