Skip to content

Commit

Permalink
Save and Restore Caret Position When Updating Content (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonalbert authored May 8, 2024
1 parent 2c0a9e7 commit e72e23b
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ open class CodeTextArea(
}

private fun updateContent() {
val position = caretPosition
code = null
when (val content = content) {
is Empty -> text = ""
Expand All @@ -82,6 +83,7 @@ open class CodeTextArea(
}
}
}
caretPosition = minOf(position, document.length)
}

final override fun addCaretListener(listener: CaretListener?) {
Expand Down

0 comments on commit e72e23b

Please # to comment.