@@ -175,17 +175,25 @@ void Symbol::serializeDocComment(llvm::json::OStream &OS) const {
175
175
176
176
OS.attributeObject (" docComment" , [&](){
177
177
auto LL = Graph->Ctx .getLineList (RC);
178
- size_t InitialIndentation = LL.getLines ().empty ()
178
+ StringRef FirstNonBlankLine;
179
+ for (const auto &Line : LL.getLines ()) {
180
+ if (!Line.Text .empty ()) {
181
+ FirstNonBlankLine = Line.Text ;
182
+ break ;
183
+ }
184
+ }
185
+ size_t InitialIndentation = FirstNonBlankLine.empty ()
179
186
? 0
180
- : markup::measureIndentation (LL. getLines (). front (). Text );
187
+ : markup::measureIndentation (FirstNonBlankLine );
181
188
OS.attributeArray (" lines" , [&](){
182
189
for (const auto &Line : LL.getLines ()) {
183
190
// Line object
184
191
OS.object ([&](){
185
192
// Trim off any initial indentation from the line's
186
193
// text and start of its source range, if it has one.
187
194
if (Line.Range .isValid ()) {
188
- serializeRange (InitialIndentation,
195
+ serializeRange (std::min (InitialIndentation,
196
+ Line.FirstNonspaceOffset ),
189
197
Line.Range , Graph->M .getASTContext ().SourceMgr , OS);
190
198
}
191
199
auto TrimmedLine = Line.Text .drop_front (std::min (InitialIndentation,
0 commit comments