Skip to content

Commit

Permalink
fix tmLanguage: text.astro pattern (#826)
Browse files Browse the repository at this point in the history
* fix(tmLanguage): text.astro pattern

* add snap test

* fix a comment
  • Loading branch information
goulvenclech authored Mar 13, 2024
1 parent f3e69cc commit db49ff7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-beers-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-vscode": patch
---

text.astro pattern matches text at the beginning and end of the document
8 changes: 5 additions & 3 deletions packages/vscode/syntaxes/astro.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "Astro",
"scopeName": "source.astro",
"fileTypes": ["astro"],
"fileTypes": [
"astro"
],
"injections": {
"L:(meta.script.astro) (meta.lang.json) - (meta source)": {
"patterns": [
Expand Down Expand Up @@ -213,8 +215,8 @@
"include": "#entities"
},
{
"begin": "(?<=>|})",
"end": "(?=<|{)",
"begin": "(?<=^|>|})",
"end": "(?=<|{|$)",
"name": "text.astro",
"patterns": [
{
Expand Down
6 changes: 3 additions & 3 deletions packages/vscode/syntaxes/astro.tmLanguage.src.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ repository:
- include: '#interpolation'
- include: '#entities'
# Content text.
# This matches only in-between all the nodes - nothing inside of them.
- begin: (?<=>|})
end: (?=<|{)
# This matches nothing inside of tags, only in-between them and at the beginning/end of the file.
- begin: (?<=^|>|})
end: (?=<|{|$)
name: text.astro
patterns:
- include: '#entities'
Expand Down
4 changes: 4 additions & 0 deletions packages/vscode/test/grammar/fixtures/text.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
text<div>text</div>
<div>text</div>text
text{"text"}
{"text"}text
28 changes: 28 additions & 0 deletions packages/vscode/test/grammar/fixtures/text.astro.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
>text<div>text</div>
#^^^^ source.astro text.astro
# ^ source.astro meta.scope.tag.div.astro meta.tag.start.astro punctuation.definition.tag.begin.astro
# ^^^ source.astro meta.scope.tag.div.astro meta.tag.start.astro entity.name.tag.astro
# ^ source.astro meta.scope.tag.div.astro meta.tag.start.astro punctuation.definition.tag.end.astro
# ^^^^ source.astro text.astro
# ^^ source.astro meta.scope.tag.div.astro meta.tag.end.astro punctuation.definition.tag.begin.astro
# ^^^ source.astro meta.scope.tag.div.astro meta.tag.end.astro entity.name.tag.astro
# ^ source.astro meta.scope.tag.div.astro meta.tag.end.astro punctuation.definition.tag.end.astro
><div>text</div>text
#^ source.astro meta.scope.tag.div.astro meta.tag.start.astro punctuation.definition.tag.begin.astro
# ^^^ source.astro meta.scope.tag.div.astro meta.tag.start.astro entity.name.tag.astro
# ^ source.astro meta.scope.tag.div.astro meta.tag.start.astro punctuation.definition.tag.end.astro
# ^^^^ source.astro text.astro
# ^^ source.astro meta.scope.tag.div.astro meta.tag.end.astro punctuation.definition.tag.begin.astro
# ^^^ source.astro meta.scope.tag.div.astro meta.tag.end.astro entity.name.tag.astro
# ^ source.astro meta.scope.tag.div.astro meta.tag.end.astro punctuation.definition.tag.end.astro
# ^^^^ source.astro text.astro
>text{"text"}
#^^^^ source.astro text.astro
# ^ source.astro punctuation.section.embedded.begin.astro
# ^^^^^^ source.astro meta.embedded.expression.astro source.tsx
# ^ source.astro punctuation.section.embedded.end.astro
>{"text"}text
#^ source.astro punctuation.section.embedded.begin.astro
# ^^^^^^ source.astro meta.embedded.expression.astro source.tsx
# ^ source.astro punctuation.section.embedded.end.astro
# ^^^^ source.astro text.astro

0 comments on commit db49ff7

Please sign in to comment.