Skip to content

Commit 88a364a

Browse files
committed
Enabled match case functionality so now the match case toggle in the find panel works.
1 parent 09555f6 commit 88a364a

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Sources/CodeEditSourceEditor/Find/FindViewController+FindPanelDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ extension FindViewController: FindPanelDelegate {
8181
self.matchCase = matchCase
8282
if !findText.isEmpty {
8383
performFind()
84+
addEmphases()
8485
}
8586
}
8687

@@ -132,7 +133,7 @@ extension FindViewController: FindPanelDelegate {
132133
return
133134
}
134135

135-
// Update to previous match
136+
// Update to previous match
136137
currentFindMatchIndex = (currentFindMatchIndex - 1 + findMatches.count) % findMatches.count
137138

138139
// If the text view has focus, show a flash animation for the current match

Sources/CodeEditSourceEditor/Find/FindViewController+Operations.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ extension FindViewController {
3232
return
3333
}
3434

35-
let findOptions: NSRegularExpression.Options = smartCase(str: findText) ? [] : [.caseInsensitive]
35+
// Set case sensitivity based on matchCase property
36+
let findOptions: NSRegularExpression.Options = matchCase ? [] : [.caseInsensitive]
3637
let escapedQuery = NSRegularExpression.escapedPattern(for: findText)
3738

3839
guard let regex = try? NSRegularExpression(pattern: escapedQuery, options: findOptions) else {
@@ -52,7 +53,7 @@ extension FindViewController {
5253
currentFindMatchIndex = getNearestEmphasisIndex(matchRanges: findMatches) ?? 0
5354
}
5455

55-
private func addEmphases() {
56+
func addEmphases() {
5657
guard let target = target,
5758
let emphasisManager = target.emphasisManager else { return }
5859

@@ -116,10 +117,4 @@ extension FindViewController {
116117

117118
// Only re-find the part of the file that changed upwards
118119
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-
}
125120
}

0 commit comments

Comments
 (0)