Skip to content

Commit edd7fdb

Browse files
committed
Fix bug in LineList end locations
LineList Line end locations were getting cut off too early because they were based on the untrimmed (w.r.t. comment markers) locations, instead of the trimmed one.
1 parent be77d57 commit edd7fdb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/Markup/LineList.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ LineList MarkupContext::getLineList(swift::RawComment RC) {
9797
auto CleanedStartLoc =
9898
C.Range.getStart().getAdvancedLocOrInvalid(CommentMarkerBytes);
9999
auto CleanedEndLoc =
100-
C.Range.getStart().getAdvancedLocOrInvalid(Cleaned.size());
100+
CleanedStartLoc.getAdvancedLocOrInvalid(Cleaned.size());
101101
Builder.addLine(Cleaned, { CleanedStartLoc, CleanedEndLoc });
102102
} else {
103103
// Skip comment markers at the beginning and at the end.
@@ -139,13 +139,13 @@ LineList MarkupContext::getLineList(swift::RawComment RC) {
139139
StringRef Line = Cleaned.substr(0, Pos);
140140
auto CleanedEndLoc = CleanedStartLoc.getAdvancedLocOrInvalid(Pos);
141141

142+
Builder.addLine(Line, { CleanedStartLoc, CleanedEndLoc });
143+
142144
Cleaned = Cleaned.drop_front(Pos);
143145
unsigned NewlineBytes = swift::measureNewline(Cleaned);
144146
Cleaned = Cleaned.drop_front(NewlineBytes);
145147
Pos += NewlineBytes;
146148
CleanedStartLoc = CleanedStartLoc.getAdvancedLocOrInvalid(Pos);
147-
148-
Builder.addLine(Line, { CleanedStartLoc, CleanedEndLoc });
149149
}
150150
}
151151
}

0 commit comments

Comments
 (0)