From fb4f41b9961b4c369e43e6b01535348c14dcd1d8 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Fri, 30 Jun 2023 14:05:35 -0400 Subject: [PATCH] Extend style to inserted text via paste or auto-correct regardless of content. --- .../securesms/components/ComposeTextStyleWatcher.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 }