File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
Tests/MarkdownTests/Parsing Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -675,10 +675,11 @@ private enum ParseContainer: CustomStringConvertible {
675675 // We need to keep track of what we removed because cmark will report different source locations than what we
676676 // had in the source. We'll adjust those when we get them back.
677677 let trimmedIndentationAndLines = lines. map { line -> ( line: TrimmedLine ,
678- indentation: TrimmedLine . Lex ? ) in
678+ indentation: Int ) in
679679 var trimmedLine = line
680680 let trimmedWhitespace = trimmedLine. lexWhitespace ( maxLength: indentationColumnCount)
681- return ( trimmedLine, trimmedWhitespace)
681+ let indentation = ( trimmedWhitespace? . text. count ?? 0 ) + line. untrimmedText. distance ( from: line. untrimmedText. startIndex, to: line. parseIndex)
682+ return ( trimmedLine, indentation)
682683 }
683684
684685 // Build the logical block of text that cmark will see.
Original file line number Diff line number Diff line change @@ -19,18 +19,18 @@ struct RangeAdjuster: MarkupWalker {
1919
2020 /// An array of whitespace spans that were removed for each line, indexed
2121 /// by line number. `nil` means that no whitespace was removed on that line.
22- var trimmedIndentationPerLine : [ TrimmedLine . Lex ? ]
22+ var trimmedIndentationPerLine : [ Int ]
2323
2424 mutating func defaultVisit( _ markup: Markup ) {
2525 /// This should only be used in the parser where ranges are guaranteed
2626 /// to be filled in from cmark.
2727 let adjustedRange = markup. range. map { range -> SourceRange in
2828 // Add back the offset to the column as if the indentation weren't stripped.
2929 let start = SourceLocation ( line: startLine + range. lowerBound. line - 1 ,
30- column: range. lowerBound. column + ( trimmedIndentationPerLine [ range. lowerBound. line - 1 ] ? . text . count ?? 0 ) ,
30+ column: range. lowerBound. column + ( trimmedIndentationPerLine [ range. lowerBound. line - 1 ] ) ,
3131 source: range. lowerBound. source)
3232 let end = SourceLocation ( line: startLine + range. upperBound. line - 1 ,
33- column: range. upperBound. column + ( trimmedIndentationPerLine [ range. upperBound. line - 1 ] ? . text . count ?? 0 ) ,
33+ column: range. upperBound. column + ( trimmedIndentationPerLine [ range. upperBound. line - 1 ] ) ,
3434 source: range. upperBound. source)
3535 return start..< end
3636 }
Original file line number Diff line number Diff line change @@ -170,8 +170,8 @@ class DoxygenCommandParserTests: XCTestCase {
170170 let expectedDump = """
171171 Document @1:1-2:39
172172 └─ DoxygenParam @1:1-2:39 parameter: thing
173- └─ Paragraph @1:1 -2:39
174- ├─ Text @1:1 -1:11 " The thing. "
173+ └─ Paragraph @1:14 -2:39
174+ ├─ Text @1:14 -1:24 " The thing. "
175175 ├─ SoftBreak
176176 └─ Text @2:1-2:39 " This is the thing that is messed with. "
177177 """
You can’t perform that action at this time.
0 commit comments