Skip to content

Commit

Permalink
Do not remove and reapply spans that start before the removed media
Browse files Browse the repository at this point in the history
  • Loading branch information
planarvoid committed Sep 15, 2023
1 parent c4572f2 commit c84ea78
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2254,16 +2254,15 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
text.getSpanEnd(blockSpan),
text.getSpanFlags(blockSpan)
)
}
}.filter { it.start >= start }
spans.forEach { temporarySpan ->
text.removeSpan(temporarySpan)
}
text.delete(start, endPlus1)
spans.forEach { temporarySpan ->
val newStart = if (temporarySpan.start >= start) temporarySpan.start - 2 else temporarySpan.start
text.setSpan(
temporarySpan.span,
newStart.coerceAtLeast(0),
(temporarySpan.start - 2).coerceAtLeast(0),
(temporarySpan.end - 2).coerceAtMost(text.length),
temporarySpan.flags
)
Expand Down

0 comments on commit c84ea78

Please sign in to comment.