Skip to content

Commit

Permalink
Make sure linebreaks are treated as ParagraphSpan.kt start/end for ma…
Browse files Browse the repository at this point in the history
…rgin
  • Loading branch information
planarvoid committed Jul 18, 2022
1 parent eb41f75 commit 8b6f7bc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions aztec/src/main/kotlin/org/wordpress/aztec/spans/ParagraphSpan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ open class ParagraphSpan(
val spanned = text as Spanned
val spanStart = spanned.getSpanStart(this)
val spanEnd = spanned.getSpanEnd(this)
val isFirstLine = start <= spanStart
val isLastLine = spanEnd <= end
val previousLineBreak = if (start > 1) {
text.substring(start-1, start) == "\n"
} else {
false
}
val followingLineBreak = if (end < text.length) {
text.substring(end, end + 1) == "\n"
} else {
false
}
val isFirstLine = start <= spanStart || previousLineBreak
val isLastLine = spanEnd <= end || followingLineBreak
if (isFirstLine) {
removeTopPadding = true
fm.ascent -= paragraphStyle.verticalMargin
Expand Down

0 comments on commit 8b6f7bc

Please sign in to comment.