Skip to content

Commit

Permalink
Merge pull request #21 from laosb/fix-cursor
Browse files Browse the repository at this point in the history
Keep cursor position after text updates when possible.
  • Loading branch information
kenmueller authored May 13, 2020
2 parents b54a3f9 + 52d783b commit 02f1d06
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/TextView/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public struct TextView: View {

public func updateUIView(_ textView: UITextView, context _: Context) {
if !shouldWaitUntilCommit || textView.markedTextRange == nil {
let selectedRange = textView.selectedRange
textView.text = text
textView.selectedRange = selectedRange
}
textView.textAlignment = textAlignment
textView.font = font
Expand Down

0 comments on commit 02f1d06

Please sign in to comment.