Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Sources/Neon/TextViewHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public final class TextViewHighlighter {

try textView.getTextStorage().delegate = storageDelegate

observeEnclosingScrollView()
observeEnclosingScrollView(expectingScrollView: false)

invalidate(.all)
}
Expand All @@ -152,11 +152,13 @@ public final class TextViewHighlighter {
extension TextViewHighlighter {
/// Begin monitoring for containing scroll view changes.
///
/// This method sets up all the necessary monitoring so the highlighter can react to scrolling. It should be called only once the view heirarchy is fully established.
public func observeEnclosingScrollView() {
/// This method sets up all the necessary monitoring so the highlighter can react to scrolling. It should be called only once the view hierarchy is fully established.
public func observeEnclosingScrollView(expectingScrollView: Bool = true) {
#if os(macOS) && !targetEnvironment(macCatalyst)
guard let scrollView = textView.enclosingScrollView else {
print("warning: there is no enclosing scroll view")
if expectingScrollView {
assertionFailure("Tried to start observing the scroll view before the view hierarchy is fully established")
}
return
}

Expand Down
Loading