Skip to content

Commit a1301d9

Browse files
Copilotandrewbranch
andcommitted
Fix getVisualListRange to use GetStartOfNode like TypeScript
Changed getVisualListRange to use astnav.GetStartOfNode() instead of next.Pos() to match TypeScript's getStart(sourceFile) behavior, which skips trivia. This fixes the range calculation from (13, 13) to the correct value by properly handling leading whitespace/trivia before the next token. Based on analysis by @andrewbranch comparing against TypeScript reference implementation in smartIndenter.ts. Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
1 parent 497174d commit a1301d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/format/indent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func getVisualListRange(node *ast.Node, list core.TextRange, sourceFile *ast.Sou
346346
if next == nil {
347347
nextStart = list.End()
348348
} else {
349-
nextStart = next.Pos()
349+
nextStart = astnav.GetStartOfNode(next, sourceFile, false)
350350
}
351351
return core.NewTextRange(priorEnd, nextStart)
352352
}

0 commit comments

Comments
 (0)