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 {
109109
110110 if hasFoundValidWordChar && CharacterSet . punctuationCharacters
111111 . union ( . whitespacesAndNewlines)
112+ . subtracting ( CharacterSet . codeIdentifierCharacters)
112113 . isSuperset ( of: CharacterSet ( charactersIn: substring) ) {
113114 stop. pointee = true
114115 return
115- } else if CharacterSet . alphanumerics . isSuperset ( of: CharacterSet ( charactersIn: substring) ) {
116+ } else if CharacterSet . codeIdentifierCharacters . isSuperset ( of: CharacterSet ( charactersIn: substring) ) {
116117 hasFoundValidWordChar = true
117118 }
118119 rangeToDelete. length += substring. count
Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ extension TextView {
3737 }
3838 let charSet = CharacterSet ( charactersIn: String ( char) )
3939 let characterSet : CharacterSet
40- if CharacterSet . alphanumerics . isSuperset ( of: charSet) {
41- characterSet = . alphanumerics
40+ if CharacterSet . codeIdentifierCharacters . isSuperset ( of: charSet) {
41+ characterSet = . codeIdentifierCharacters
4242 } else if CharacterSet . whitespaces. isSuperset ( of: charSet) {
4343 characterSet = . whitespaces
4444 } else if CharacterSet . newlines. isSuperset ( of: charSet) {
You can’t perform that action at this time.
0 commit comments