From 5f9d0d9906b2733f3d60a89fc3825202ef243722 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Tue, 9 Jul 2024 10:07:06 -0700 Subject: [PATCH] fix(syntaxes): inject template tags to top-level source.ts 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. fixes #2053 --- .../npm_translate_lock_LTE4Nzc1MDcwNjU= | 2 +- package.json | 9 ++++++--- syntaxes/inline-template.json | 5 +---- syntaxes/src/inline-template.ts | 15 +++++++++------ syntaxes/test/data/inline-template.ts.snap | 18 +++++++++--------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= b/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= index e5f26912be..dbbb66e23e 100755 --- a/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= +++ b/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= @@ -4,5 +4,5 @@ .npmrc=974837034 pnpm-lock.yaml=1988059937 yarn.lock=448809282 -package.json=-1818990980 +package.json=-1372627236 pnpm-workspace.yaml=1711114604 diff --git a/package.json b/package.json index ed1720c072..35bbcce481 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "source.ts" ], "embeddedLanguages": { - "text.html": "html", + "text.html.derivative": "html", "source.css": "css", "source.js": "javascript" } @@ -174,12 +174,15 @@ { "path": "./syntaxes/let-declaration.json", "scopeName": "template.let.ng", - "injectTo": [ "text.html.derivative" ] + "injectTo": ["text.html.derivative"] }, { "path": "./syntaxes/template-tag.json", "scopeName": "template.tag.ng", - "injectTo": ["text.html.derivative"] + "injectTo": [ + "text.html.derivative", + "source.ts" + ] }, { "path": "./syntaxes/expression.json", diff --git a/syntaxes/inline-template.json b/syntaxes/inline-template.json index 04c9886424..e2e0f1fbd5 100644 --- a/syntaxes/inline-template.json +++ b/syntaxes/inline-template.json @@ -62,7 +62,7 @@ "name": "string" } }, - "contentName": "text.html", + "contentName": "text.html.derivative", "patterns": [ { "include": "text.html.derivative" @@ -73,9 +73,6 @@ { "include": "template.blocks.ng" }, - { - "include": "template.tag.ng" - }, { "include": "template.let.ng" } diff --git a/syntaxes/src/inline-template.ts b/syntaxes/src/inline-template.ts index 38294239ba..ff062833d2 100644 --- a/syntaxes/src/inline-template.ts +++ b/syntaxes/src/inline-template.ts @@ -37,13 +37,16 @@ export const InlineTemplate: GrammarDefinition = { // @ts-ignore end: /\1/, endCaptures: {0: {name: 'string'}}, - contentName: 'text.html', + contentName: 'text.html.derivative', patterns: [ - {include: 'text.html.derivative'}, - {include: 'template.ng'}, - {include: 'template.blocks.ng'}, - {include: 'template.tag.ng'}, - {include: 'template.let.ng'}, + {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. ] } } diff --git a/syntaxes/test/data/inline-template.ts.snap b/syntaxes/test/data/inline-template.ts.snap index 5d0bdf021f..131c015cc2 100644 --- a/syntaxes/test/data/inline-template.ts.snap +++ b/syntaxes/test/data/inline-template.ts.snap @@ -13,7 +13,7 @@ # ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts # ^ inline-template.ng # ^ inline-template.ng string -# ^^^^^^^^^^^ inline-template.ng text.html +# ^^^^^^^^^^^ inline-template.ng text.html.derivative # ^ inline-template.ng string # ^^ inline-template.ng > @@ -25,7 +25,7 @@ # ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts # ^ inline-template.ng # ^ inline-template.ng string -# ^^^^^^^^^^^ inline-template.ng text.html +# ^^^^^^^^^^^ inline-template.ng text.html.derivative # ^ inline-template.ng string # ^^ inline-template.ng > template: "
", @@ -34,7 +34,7 @@ # ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts # ^ inline-template.ng # ^ inline-template.ng string -# ^^^^^^^^^^^ inline-template.ng text.html +# ^^^^^^^^^^^ inline-template.ng text.html.derivative # ^ inline-template.ng string # ^^ inline-template.ng > template: '
', @@ -43,7 +43,7 @@ # ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts # ^ inline-template.ng # ^ inline-template.ng string -# ^^^^^^^^^^^ inline-template.ng text.html +# ^^^^^^^^^^^ inline-template.ng text.html.derivative # ^ inline-template.ng string # ^^ inline-template.ng > @@ -60,7 +60,7 @@ # ^ inline-template.ng meta.brace.round.ts # ^ inline-template.ng # ^ inline-template.ng string -# ^^^^^^^^^^^ inline-template.ng text.html +# ^^^^^^^^^^^ inline-template.ng text.html.derivative # ^ inline-template.ng string # ^ inline-template.ng # ^ inline-template.ng meta.brace.round.ts @@ -77,7 +77,7 @@ # ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts # ^ inline-template.ng # ^ inline-template.ng string -# ^^^^^^^^^^^ inline-template.ng text.html +# ^^^^^^^^^^^ inline-template.ng text.html.derivative # ^ inline-template.ng string > /* #^^^^^ inline-template.ng @@ -108,9 +108,9 @@ # ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts # ^ inline-template.ng # ^ inline-template.ng string -# ^^ inline-template.ng text.html punctuation.definition.block.ts -# ^^^^^^^^ inline-template.ng text.html expression.ng variable.other.readwrite.ts -# ^^ inline-template.ng text.html punctuation.definition.block.ts +# ^^ inline-template.ng text.html.derivative punctuation.definition.block.ts +# ^^^^^^^^ inline-template.ng text.html.derivative expression.ng variable.other.readwrite.ts +# ^^ inline-template.ng text.html.derivative punctuation.definition.block.ts # ^ inline-template.ng string # ^^ inline-template.ng >})