Forcibly cast notification object

This commit is contained in:
1024jp 2024-07-01 00:33:04 +09:00
parent 407e031e36
commit 9e65605585
3 changed files with 4 additions and 4 deletions

View File

@ -88,9 +88,9 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
// observe find result notifications from TextFinder and its expiration
self.resultObservers = [
NotificationCenter.default.publisher(for: TextFinder.didFindNotification)
.map { $0.object as? TextFinder }
.map { $0.object as! TextFinder }
.receive(on: RunLoop.main)
.sink { [weak self] in self?.update(result: $0?.findResult) },
.sink { [weak self] in self?.update(result: $0.findResult) },
NotificationCenter.default.publisher(for: NSWindow.didResignMainNotification)
.sink { [weak self] _ in self?.update(result: nil) },
]

View File

@ -54,7 +54,7 @@ import ValueRange
self.inconsistentLineEndings = self.lineEndings.filter { $0.value != lineEnding }
self.storageObserver = NotificationCenter.default.publisher(for: NSTextStorage.didProcessEditingNotification, object: textStorage)
.compactMap { $0.object as? NSTextStorage }
.map { $0.object as! NSTextStorage }
.filter { $0.editedMask.contains(.editedCharacters) }
.sink { [weak self] in self?.invalidate(string: $0.string, in: $0.editedRange, changeInLength: $0.changeInLength) }
}

View File

@ -349,7 +349,7 @@ final class LineNumberView: NSView {
.sink { [weak self] in
self?.invalidateThickness()
self?.textStorageObserver = NotificationCenter.default.publisher(for: NSTextStorage.didProcessEditingNotification, object: $0)
.compactMap { $0.object as? NSTextStorage }
.map { $0.object as! NSTextStorage }
.filter { $0.editedMask.contains(.editedCharacters) }
.receive(on: RunLoop.main) // touch textView on main thread
.sink { [weak self] _ in