From 1d2a9ae22f8c5b7d83b874d8924fa16282dad691 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Wed, 13 May 2020 20:25:56 +0800 Subject: [PATCH 1/2] fix: restore cursor pos. --- Sources/TextView/TextView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/TextView/TextView.swift b/Sources/TextView/TextView.swift index 3d63572..4fe6c37 100644 --- a/Sources/TextView/TextView.swift +++ b/Sources/TextView/TextView.swift @@ -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 From 52d783bd7b8e1a180d497f38ae9fb0c64044d728 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Thu, 14 May 2020 01:31:28 +0800 Subject: [PATCH 2/2] Fix indentation (again) Sorry for not realizing this... --- Sources/TextView/TextView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/TextView/TextView.swift b/Sources/TextView/TextView.swift index 4fe6c37..ee6231d 100644 --- a/Sources/TextView/TextView.swift +++ b/Sources/TextView/TextView.swift @@ -95,9 +95,9 @@ public struct TextView: View { public func updateUIView(_ textView: UITextView, context _: Context) { if !shouldWaitUntilCommit || textView.markedTextRange == nil { - let selectedRange = textView.selectedRange + let selectedRange = textView.selectedRange textView.text = text - textView.selectedRange = selectedRange + textView.selectedRange = selectedRange } textView.textAlignment = textAlignment textView.font = font