File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
Sources/CodeEditSourceEditor/Find Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ extension FindViewController: FindPanelDelegate {
81
81
self . matchCase = matchCase
82
82
if !findText. isEmpty {
83
83
performFind ( )
84
+ addEmphases ( )
84
85
}
85
86
}
86
87
@@ -132,7 +133,7 @@ extension FindViewController: FindPanelDelegate {
132
133
return
133
134
}
134
135
135
- // Update to previous match∂
136
+ // Update to previous match
136
137
currentFindMatchIndex = ( currentFindMatchIndex - 1 + findMatches. count) % findMatches. count
137
138
138
139
// If the text view has focus, show a flash animation for the current match
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ extension FindViewController {
32
32
return
33
33
}
34
34
35
- let findOptions : NSRegularExpression . Options = smartCase ( str: findText) ? [ ] : [ . caseInsensitive]
35
+ // Set case sensitivity based on matchCase property
36
+ let findOptions : NSRegularExpression . Options = matchCase ? [ ] : [ . caseInsensitive]
36
37
let escapedQuery = NSRegularExpression . escapedPattern ( for: findText)
37
38
38
39
guard let regex = try ? NSRegularExpression ( pattern: escapedQuery, options: findOptions) else {
@@ -52,7 +53,7 @@ extension FindViewController {
52
53
currentFindMatchIndex = getNearestEmphasisIndex ( matchRanges: findMatches) ?? 0
53
54
}
54
55
55
- private func addEmphases( ) {
56
+ func addEmphases( ) {
56
57
guard let target = target,
57
58
let emphasisManager = target. emphasisManager else { return }
58
59
@@ -116,10 +117,4 @@ extension FindViewController {
116
117
117
118
// Only re-find the part of the file that changed upwards
118
119
private func reFind( ) { }
119
-
120
- // Returns true if string contains uppercase letter
121
- // used for: ignores letter case if the find text is all lowercase
122
- private func smartCase( str: String ) -> Bool {
123
- return str. range ( of: " [A-Z] " , options: . regularExpression) != nil
124
- }
125
120
}
You can’t perform that action at this time.
0 commit comments