File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,12 +142,21 @@ final class UXCodeTextView: UXTextView {
142142 if coordinator. allowCopy { super. copy ( sender) }
143143 }
144144
145-
145+ private var isAutoPairEnabled : Bool { return !autoPairCompletion. isEmpty }
146+
147+ #if os(iOS)
148+ override func insertText( _ text: String ) {
149+ super. insertText ( text)
150+ guard isAutoPairEnabled else { return }
151+ guard let end = autoPairCompletion [ text] else { return }
152+ let prev = self . selectedRange
153+ super. insertText ( end)
154+ self . selectedRange = prev
155+ }
156+ #endif
146157 #if os(macOS)
147158 // MARK: - Smarts as shown in https://github.com/naoty/NTYSmartTextView
148159
149- private var isAutoPairEnabled : Bool { return !autoPairCompletion. isEmpty }
150-
151160 override func insertNewline( _ sender: Any ? ) {
152161 guard isSmartIndentEnabled else { return super. insertNewline ( sender) }
153162
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ struct UXCodeTextViewRepresentable : UXViewRepresentable {
195195 textView. indentStyle = indentStyle
196196 textView. isSmartIndentEnabled = flags. contains ( . smartIndent)
197197 textView. autoPairCompletion = autoPairs
198-
198+
199199 if source. wrappedValue != textView. string {
200200 if let textStorage = textView. codeTextStorage {
201201 textStorage. replaceCharacters ( in : NSMakeRange ( 0 , textStorage. length) ,
@@ -269,6 +269,10 @@ struct UXCodeTextViewRepresentable : UXViewRepresentable {
269269 textView. autoresizingMask = [ . flexibleWidth, . flexibleHeight ]
270270 textView. delegate = context. coordinator
271271 textView. textContainerInset = edgeInsets
272+ #if os(iOS)
273+ textView. autocapitalizationType = . none
274+ textView. smartDashesType = . no
275+ #endif
272276 updateTextView ( textView)
273277 return textView
274278 }
You can’t perform that action at this time.
0 commit comments