Skip to content

Commit

Permalink
Fix line computation
Browse files Browse the repository at this point in the history
  • Loading branch information
badoualy committed Mar 22, 2023
1 parent 320a765 commit 67b1618
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ internal fun TextLayoutResult.getLines(): String {
val input = layoutInput.text.toString()
if (input.isEmpty()) return ""

return buildString {
var currentIndex = 0

repeat(lineCount) { line ->
val lineEnd = getLineEnd(line)
appendLine(input.substring(currentIndex, lineEnd))

currentIndex = lineEnd
}
}.trim()
return (0 until lineCount).joinToString("\n") { line ->
val lineContent = input.substring(
getLineStart(line),
getLineEnd(line, visibleEnd = true)
)
lineContent
}
}

0 comments on commit 67b1618

Please sign in to comment.