We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3ddd279 commit 2b0c29eCopy full SHA for 2b0c29e
Sources/CodeEditTextView/TextView/TextView+ReplaceCharacters.swift
@@ -42,6 +42,12 @@ extension TextView {
42
layoutManager.endTransaction()
43
selectionManager.notifyAfterEdit()
44
NotificationCenter.default.post(name: Self.textDidChangeNotification, object: self)
45
+
46
+ // `scrollSelectionToVisible` is a little expensive to call every time. Instead we just check if the first
47
+ // selection is entirely visible. `.contains` checks that all points in the rect are inside.
48
+ if let selection = selectionManager.textSelections.first, !visibleRect.contains(selection.boundingRect) {
49
+ scrollSelectionToVisible()
50
+ }
51
}
52
53
/// Replace the characters in a range with a new string.
0 commit comments