Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions internal/bcl/internal/parser/fmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ func TestFmtDiff(t *testing.T) {
{1, 3, "\n"},
},
})

run("comment align", testCase{
// Tests a bug where the comment on field f caused the block header not
// to have an end in the source, so the diff ranged from 2 to 0.

input: s(
"", // ensures that the field with the comment is not on line 1, which would prevent the panic
"object {",
"field f // open",
"}",
),
expected: []FmtDiff{
{0, 1, ""},
{2, 3, "\tfield f // open\n"},
},
})
}

type slicePop[T any] struct {
Expand Down
1 change: 1 addition & 0 deletions internal/bcl/internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ func (ww *Walker) walkStatement() (Fragment, *unexpectedTokenError) {
if comment != nil {
hdr.Comment = comment
}
hdr.End = ww.currentPos()
return hdr, nil

case EOL, EOF:
Expand Down