diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt b/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt index ebc396d4f..b0890ce90 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt @@ -2433,6 +2433,18 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown this.uncaughtExceptionHandler = null } + override fun setSelection(index: Int) { + if (index in 0..this.length()) { + super.setSelection(index) + } else if (index < 0) { + AppLog.e(AppLog.T.EDITOR, "Attempted to set selection to incorrect value $index") + setSelection(0) + } else if (index > this.length()) { + AppLog.e(AppLog.T.EDITOR, "Attempted to set selection to incorrect value $index") + setSelection(this.length()) + } + } + override fun dispatchHoverEvent(event: MotionEvent): Boolean { return if (accessibilityDelegate.onHoverEvent(event)) true else super.dispatchHoverEvent(event) }