Skip to content

Commit aa7829a

Browse files
Apply suggestions from code review
Co-authored-by: Khan Winter <35942988+thecoolwinter@users.noreply.github.com>
1 parent 5b8a052 commit aa7829a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Sources/CodeEditSourceEditor/Find/ViewModel/FindPanelViewModel+Find.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ extension FindPanelViewModel {
5454

5555
guard let regex = try? NSRegularExpression(pattern: pattern, options: findOptions) else {
5656
self.findMatches = []
57-
self.currentFindMatchIndex = 0
57+
self.currentFindMatchIndex = nil
5858
return
5959
}
6060

6161
let text = target.textView.string
62-
let nsText = text as NSString
63-
let range = NSRange(location: 0, length: nsText.length)
64-
let matches = regex.matches(in: text, range: range)
62+
let range = target.textView.documentRange
63+
let matches = regex.matches(in: text, range: range).filter { !$0.range.isEmpty }
6564

6665
self.findMatches = matches.map(\.range)
6766

0 commit comments

Comments
 (0)