From 56a3798735e2bfa7d3b16d2d03b284d81c862667 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 26 Feb 2024 10:35:18 -0500 Subject: [PATCH] Check for selectionStart being -1 to fix talkback crash in Day One --- .../kotlin/org/wordpress/aztec/formatting/IndentFormatter.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/formatting/IndentFormatter.kt b/aztec/src/main/kotlin/org/wordpress/aztec/formatting/IndentFormatter.kt index f91cd18e8..b3ecd812e 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/formatting/IndentFormatter.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/formatting/IndentFormatter.kt @@ -167,6 +167,9 @@ class IndentFormatter(editor: AztecText) : AztecFormatter(editor) { * Checks whether any line of the selection can be outdented */ fun isOutdentAvailable(): Boolean { + if (selectionStart == -1) { + return false + } val previousLineBreak = editableText.substring(0, selectionStart).lastIndexOf("\n") if (previousLineBreak > 0 && selectionCanBeOutdented(previousLineBreak + 1, selectionStart)) { return true