File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
TextSelectionManager/SelectionManipulation Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // CharacterSet.swift
3
+ // CodeEditTextView
4
+ //
5
+ // Created by Abe Malla on 3/29/25.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ extension CharacterSet {
11
+ /// Returns a character set containing the characters common in code names
12
+ static let codeIdentifierCharacters : CharacterSet = . alphanumerics
13
+ . union ( . init( charactersIn: " _ " ) )
14
+ }
Original file line number Diff line number Diff line change @@ -109,10 +109,11 @@ package extension TextSelectionManager {
109
109
110
110
if hasFoundValidWordChar && CharacterSet . punctuationCharacters
111
111
. union ( . whitespacesAndNewlines)
112
+ . subtracting ( CharacterSet . codeIdentifierCharacters)
112
113
. isSuperset ( of: CharacterSet ( charactersIn: substring) ) {
113
114
stop. pointee = true
114
115
return
115
- } else if CharacterSet . alphanumerics . isSuperset ( of: CharacterSet ( charactersIn: substring) ) {
116
+ } else if CharacterSet . codeIdentifierCharacters . isSuperset ( of: CharacterSet ( charactersIn: substring) ) {
116
117
hasFoundValidWordChar = true
117
118
}
118
119
rangeToDelete. length += substring. count
Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ extension TextView {
37
37
}
38
38
let charSet = CharacterSet ( charactersIn: String ( char) )
39
39
let characterSet : CharacterSet
40
- if CharacterSet . alphanumerics . isSuperset ( of: charSet) {
41
- characterSet = . alphanumerics
40
+ if CharacterSet . codeIdentifierCharacters . isSuperset ( of: charSet) {
41
+ characterSet = . codeIdentifierCharacters
42
42
} else if CharacterSet . whitespaces. isSuperset ( of: charSet) {
43
43
characterSet = . whitespaces
44
44
} else if CharacterSet . newlines. isSuperset ( of: charSet) {
You can’t perform that action at this time.
0 commit comments