diff --git a/platforms/android/library/src/main/java/io/element/android/wysiwyg/inputhandlers/InterceptInputConnection.kt b/platforms/android/library/src/main/java/io/element/android/wysiwyg/inputhandlers/InterceptInputConnection.kt index b48068536..c07db7cac 100644 --- a/platforms/android/library/src/main/java/io/element/android/wysiwyg/inputhandlers/InterceptInputConnection.kt +++ b/platforms/android/library/src/main/java/io/element/android/wysiwyg/inputhandlers/InterceptInputConnection.kt @@ -9,6 +9,7 @@ import android.view.inputmethod.* import android.widget.TextView import androidx.annotation.RequiresApi import androidx.annotation.VisibleForTesting +import androidx.core.text.isDigitsOnly import io.element.android.wysiwyg.internal.utils.TextRangeHelper import io.element.android.wysiwyg.internal.viewmodel.EditorInputAction import io.element.android.wysiwyg.internal.viewmodel.ReplaceTextResult @@ -322,7 +323,11 @@ internal class InterceptInputConnection( beginBatchEdit() editable.removeFormattingSpans() editable.replace(0, editable.length, charSequence) - setComposingRegion(compositionStart, compositionEnd) + val start = compositionStart.coerceIn(0, editable.length) + val end = compositionEnd.coerceIn(0, editable.length) + if (!editable.substring(start, end).isDigitsOnly()) { + setComposingRegion(start, end) + } endBatchEdit() }