From 0a9b89c15cbdf7bd6b21330d1c8fae54ce2cae89 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 25 Apr 2024 08:24:50 +0200 Subject: [PATCH] Preserve position without crashing --- src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/DexTextArea.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/DexTextArea.kt b/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/DexTextArea.kt index e143fbf8..0460f4b8 100644 --- a/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/DexTextArea.kt +++ b/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/DexTextArea.kt @@ -26,7 +26,7 @@ private val AddressedPattern = Regex("(\\s+)([0-9a-fA-F]{4}): .+[\\n\\r]*") internal fun updateTextArea(textArea: RSyntaxTextArea, text: String) { val position = textArea.caretPosition textArea.text = text - textArea.caretPosition = position + textArea.caretPosition = minOf(position, textArea.document.length) } class DexTextArea : RSyntaxTextArea() {