Skip to content

Commit ecf39e3

Browse files
committed
Fixed first line detection and updated formatting.
1 parent c511405 commit ecf39e3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/spans/AztecPreformatSpan.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ open class AztecPreformatSpan(
9797

9898
override fun drawBackground(canvas: Canvas, paint: Paint, left: Int, right: Int, top: Int, baseline: Int,
9999
bottom: Int, text: CharSequence?, start: Int, end: Int, lnum: Int) {
100-
101100
val spanned = text as Spanned
101+
val spanStart = spanned.getSpanStart(this)
102102
val spanEnd = spanned.getSpanEnd(this)
103103

104-
val alpha: Int = (preformatStyle.preformatBackgroundAlpha * 255).toInt()
104+
val isFirstLine = spanStart == start
105+
val isLastLine = spanEnd == end
105106

107+
val alpha: Int = (preformatStyle.preformatBackgroundAlpha * 255).toInt()
106108
fillPaint.color = Color.argb(
107109
alpha,
108110
Color.red(preformatStyle.preformatBackground),
@@ -116,10 +118,6 @@ open class AztecPreformatSpan(
116118
strokePaint.color = preformatStyle.preformatBorderColor
117119
strokePaint.strokeWidth = preformatStyle.preformatBorderThickness.toFloat()
118120

119-
val isFirstLine = top == 0
120-
121-
val isLastLine = spanEnd == end
122-
123121
val fillPath = Path().apply {
124122
if (isFirstLine) {
125123
moveTo(left.toFloat(), bottom.toFloat())

0 commit comments

Comments
 (0)