Skip to content

Commit bd973a2

Browse files
authored
Merge pull request #3332 from nojaf/correct-range
Use combined range for CommentOnSingleLineWithLeadingNewlines
2 parents 4071780 + db81022 commit bd973a2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/Fantomas.Core/Trivia.fs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,15 @@ let promoteNewlinesBeforeComments (trivia: TriviaNode array) : TriviaNode array
419419

420420
pendingNewlines.Add(t)
421421
| CommentOnSingleLine comment when lastPendingNewlineIsAdjacentTo t.Range.StartLine && t.Range.StartColumn > 0 ->
422-
result.Add(TriviaNode(CommentOnSingleLineWithLeadingNewlines(pendingNewlines.Count, comment), t.Range))
422+
let startPos =
423+
Position.mkPos pendingNewlines.[0].Range.StartLine t.Range.StartColumn
424+
425+
let combinedRange = Range.mkFileIndexRange t.Range.FileIndex startPos t.Range.End
426+
427+
result.Add(
428+
TriviaNode(CommentOnSingleLineWithLeadingNewlines(pendingNewlines.Count, comment), combinedRange)
429+
)
430+
423431
pendingNewlines.Clear()
424432
| _ ->
425433
flushPendingNewlines ()

0 commit comments

Comments
 (0)