Skip to content

Commit 035829b

Browse files
authored
fix(ast): move end position for elements (#591)
Co-authored-by: Nate Moore <[email protected]>
1 parent 5d3923f commit 035829b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/cuddly-deers-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/compiler': patch
3+
---
4+
5+
AST: move end position of elements to the last index of their end tag

internal/printer/print-to-json.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ func positionAt(p *printer, n *Node, opts t.ParseOptions) ASTPosition {
143143
if len(n.Loc) == 2 {
144144
s := n.Loc[0]
145145
e := n.Loc[1]
146+
// `e` marks the start location of the end tag
147+
if n.Type == ElementNode {
148+
// this adjusts it to be the last index of the end tag
149+
e.Start = e.Start + len(n.Data) + 1
150+
}
146151
start := locToPoint(p, s)
147152
end := locToPoint(p, e)
148153

0 commit comments

Comments
 (0)