Skip to content

Commit

Permalink
Updated to fix macOS overlay error.
Browse files Browse the repository at this point in the history
  • Loading branch information
twostraws committed May 12, 2019
1 parent a6339ee commit 398e90f
Show file tree
Hide file tree
Showing 2 changed files with 491 additions and 490 deletions.
17 changes: 15 additions & 2 deletions Sources/View/LineNumberLayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class LineNumberLayoutManager: NSLayoutManager {
return paraNumber
}
}

override func processEditing(for textStorage: NSTextStorage, edited editMask: NSTextStorage.EditActions, range newCharRange: NSRange, changeInLength delta: Int, invalidatedRange invalidatedCharRange: NSRange) {

#if os(macOS)
override func processEditing(for textStorage: NSTextStorage, edited editMask: NSTextStorageEditActions, range newCharRange: NSRange, changeInLength delta: Int, invalidatedRange invalidatedCharRange: NSRange) {
super.processEditing(for: textStorage, edited: editMask, range: newCharRange, changeInLength: delta, invalidatedRange: invalidatedCharRange)
if invalidatedCharRange.location < lastParaLocation {
// When the backing store is edited ahead the cached paragraph location, invalidate the cache and force a complete
Expand All @@ -74,6 +75,18 @@ class LineNumberLayoutManager: NSLayoutManager {
lastParaNumber = 0
}
}
#else
override func processEditing(for textStorage: NSTextStorage, edited editMask: NSTextStorage.EditActions, range newCharRange: NSRange, changeInLength delta: Int, invalidatedRange invalidatedCharRange: NSRange) {
super.processEditing(for: textStorage, edited: editMask, range: newCharRange, changeInLength: delta, invalidatedRange: invalidatedCharRange)
if invalidatedCharRange.location < lastParaLocation {
// When the backing store is edited ahead the cached paragraph location, invalidate the cache and force a complete
// recalculation. We cannot be much smarter than this because we don't know how many paragraphs have been deleted
// since the text has already been removed from the backing store.
lastParaLocation = 0
lastParaNumber = 0
}
}
#endif

var gutterWidth: CGFloat = 0.0

Expand Down
Loading

0 comments on commit 398e90f

Please sign in to comment.