-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
The crash happens due to the caret wanting to move left when there is nothing.
I was going to PR it but because it can be fixed in multiple places and I wasn't sure which place would be best so, I thought I should make an issue first.
The error is:
Exception in thread "kool-main-backend-thread" java.lang.IllegalArgumentException: max (-1) is smaller than min (0)
at de.fabmax.kool.util.TextCaretNavigation.moveWordLeft(TextCaretNavigation.kt:62)
at de.fabmax.kool.util.EditableText.moveWordLeft(EditableText.kt:51)
at de.fabmax.kool.util.EditableText.moveCaret(EditableText.kt:42)
at de.fabmax.kool.modules.ui2.TextFieldNode.onClick(TextField.kt:263)
at de.fabmax.kool.modules.ui2.UiModifierKt$onClick$1.invoke(UiModifier.kt:298)
at de.fabmax.kool.modules.ui2.UiModifierKt$onClick$1.invoke(UiModifier.kt:298)
at de.fabmax.kool.modules.ui2.UiSurface$UiInputHandler.invokePointerCallback(UiSurface.kt:557)
at de.fabmax.kool.modules.ui2.UiSurface$UiInputHandler.invokePointerCallback$default(UiSurface.kt:545)
It can be fixed by add && editText.text.isNotEmpty() to the double click condition in the TextField#onClick, or in TextCaretNavigation#moveWordLeft adding if (text.isEmpty()) return 0 which probably makes more sense since the other functions above it already do the same check.
Let me know which one you prefer and I am happy to PR too!
Metadata
Metadata
Assignees
Labels
No labels