diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ComposeTextStyleWatcher.kt b/app/src/main/java/org/thoughtcrime/securesms/components/ComposeTextStyleWatcher.kt index 2de670ac40..db3230e6c1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ComposeTextStyleWatcher.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ComposeTextStyleWatcher.kt @@ -46,11 +46,17 @@ class ComposeTextStyleWatcher : TextWatcher { try { if (editStart < 0 || editEnd < 0 || editStart >= editEnd || (editStart == 0 && editEnd == s.length)) { + textSnapshotPriorToChange = null return } val change = s.subSequence(editStart, editEnd) - if (change.isEmpty() || textSnapshotPriorToChange == null || (editEnd - editStart == 1 && !StringUtil.isVisuallyEmpty(change[0])) || TextUtils.equals(textSnapshotPriorToChange, change)) { + if (change.isEmpty() || + textSnapshotPriorToChange == null || + (editEnd - editStart == 1 && !StringUtil.isVisuallyEmpty(change[0])) || + TextUtils.equals(textSnapshotPriorToChange, change) || + editEnd - editStart > 1 + ) { textSnapshotPriorToChange = null return }