diff --git a/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/code/CodeTextArea.kt b/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/code/CodeTextArea.kt index 19a1c27c..1517b8d5 100644 --- a/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/code/CodeTextArea.kt +++ b/src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/code/CodeTextArea.kt @@ -71,6 +71,7 @@ open class CodeTextArea( } private fun updateContent() { + val position = caretPosition code = null when (val content = content) { is Empty -> text = "" @@ -82,6 +83,7 @@ open class CodeTextArea( } } } + caretPosition = minOf(position, document.length) } final override fun addCaretListener(listener: CaretListener?) {