mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Reduce implict unwrapping
This commit is contained in:
parent
566fdfea44
commit
13515f4067
@ -13,6 +13,7 @@ develop
|
||||
- Fix a possible crash on application termination.
|
||||
- Fix a possible crash on opening document.
|
||||
- Fix error message of syntax style valitation.
|
||||
- Improve general stability.
|
||||
|
||||
|
||||
|
||||
|
@ -48,7 +48,9 @@ extension EditorTextView {
|
||||
let selectedRanges = self.selectedRanges as [NSRange]
|
||||
|
||||
// register redo for text selection
|
||||
(self.undoManager?.prepare(withInvocationTarget: self) as! NSTextView).setSelectedRangesWithUndo(self.selectedRanges as [NSRange])
|
||||
if let undoClient = self.undoManager?.prepare(withInvocationTarget: self) as? NSTextView {
|
||||
undoClient.setSelectedRangesWithUndo(self.selectedRanges as [NSRange])
|
||||
}
|
||||
|
||||
var newSelectedRanges = [NSRange]()
|
||||
|
||||
@ -115,7 +117,9 @@ extension EditorTextView {
|
||||
let selectedRanges = self.selectedRanges as [NSRange]
|
||||
|
||||
// register redo for text selection
|
||||
(self.undoManager?.prepare(withInvocationTarget: self) as! NSTextView).setSelectedRangesWithUndo(self.selectedRanges as [NSRange])
|
||||
if let undoClient = self.undoManager?.prepare(withInvocationTarget: self) as? NSTextView {
|
||||
undoClient.setSelectedRangesWithUndo(self.selectedRanges as [NSRange])
|
||||
}
|
||||
|
||||
var newSelectedRanges = [NSRange]()
|
||||
|
||||
|
@ -54,7 +54,9 @@ extension NSTextView {
|
||||
guard !strings.isEmpty, let textStorage = self.textStorage else { return false }
|
||||
|
||||
// register redo for text selection
|
||||
(self.undoManager?.prepare(withInvocationTarget: self) as! NSTextView).setSelectedRangesWithUndo(self.selectedRanges as [NSRange])
|
||||
if let undoClient = self.undoManager?.prepare(withInvocationTarget: self) as? NSTextView {
|
||||
undoClient.setSelectedRangesWithUndo(self.selectedRanges as [NSRange])
|
||||
}
|
||||
|
||||
// tell textEditor about beginning of the text processing
|
||||
guard self.shouldChangeText(inRanges: ranges as [NSValue], replacementStrings: strings) else { return false }
|
||||
@ -88,8 +90,12 @@ extension NSTextView {
|
||||
/// undoable selection change
|
||||
@objc func setSelectedRangesWithUndo(_ ranges: [NSRange]) {
|
||||
|
||||
self.selectedRanges = ranges as [NSValue]
|
||||
(self.undoManager?.prepare(withInvocationTarget: self) as! NSTextView).setSelectedRangesWithUndo(ranges)
|
||||
guard let undoClient = self.undoManager?.prepare(withInvocationTarget: self) as? NSTextView else {
|
||||
assertionFailure("failed preparing undo.")
|
||||
return
|
||||
}
|
||||
|
||||
undoClient.setSelectedRangesWithUndo(ranges as [NSRange])
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,12 +244,11 @@ final class TextFinder: NSResponder, TextFinderSettingsProvider {
|
||||
|
||||
let integerFormatter = self.integerFormatter
|
||||
let findString = self.sanitizedFindString
|
||||
let regex = self.regex()!
|
||||
let scopeRanges = self.scopeRanges
|
||||
|
||||
self.busyTextViews.insert(textView)
|
||||
|
||||
let numberOfGroups = regex.numberOfCaptureGroups
|
||||
let numberOfGroups = self.regex()?.numberOfCaptureGroups ?? 0
|
||||
let highlightColors = self.highlightColor.decomposite(into: numberOfGroups + 1)
|
||||
|
||||
let lineRegex = try! NSRegularExpression(pattern: "\n")
|
||||
|
Loading…
Reference in New Issue
Block a user