From e290a542929aeb3a2bc471681273f8130f2b118f Mon Sep 17 00:00:00 2001 From: jhavens1566 Date: Sun, 15 Sep 2024 19:05:24 -0600 Subject: [PATCH] fix(markdown): ToggleCheckboxCa.java crash Fix crash when untoggling a checkbox, caused by Editable.replace end < start. --- .../android/markdown/controller/applier/ToggleCheckboxCa.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/markdown/src/main/java/it/niedermann/android/markdown/controller/applier/ToggleCheckboxCa.java b/markdown/src/main/java/it/niedermann/android/markdown/controller/applier/ToggleCheckboxCa.java index 9a8f592..ad26cc0 100644 --- a/markdown/src/main/java/it/niedermann/android/markdown/controller/applier/ToggleCheckboxCa.java +++ b/markdown/src/main/java/it/niedermann/android/markdown/controller/applier/ToggleCheckboxCa.java @@ -47,10 +47,10 @@ public class ToggleCheckboxCa implements CommandApplier { newSelection = selectionEnd + previousLineListType.checkboxUncheckedWithTrailingSpace.length(); } else { if (startOfLine + listType.checkboxUncheckedWithTrailingSpace.length() > endOfLine) { - content.replace(startOfLine, listType.checkboxUnchecked.length(), ""); + content.replace(startOfLine, startOfLine + listType.checkboxUnchecked.length(), ""); newSelection = selectionEnd - listType.checkboxUnchecked.length(); } else { - content.replace(startOfLine, listType.checkboxUncheckedWithTrailingSpace.length(), ""); + content.replace(startOfLine, startOfLine + listType.checkboxUncheckedWithTrailingSpace.length(), ""); newSelection = selectionEnd - listType.checkboxUncheckedWithTrailingSpace.length(); } }