Prevent link activation when outside character

This commit is contained in:
Shadowfacts 2020-08-16 14:52:08 -04:00
parent be81ffb61f
commit ee20c95a5d
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 1 additions and 1 deletions

View File

@ -197,7 +197,7 @@ class ContentTextView: LinkTextView {
let locationInTextContainer = CGPoint(x: point.x - textContainerInset.left, y: point.y - textContainerInset.top)
var partialFraction: CGFloat = 0
let characterIndex = layoutManager.characterIndex(for: locationInTextContainer, in: textContainer, fractionOfDistanceBetweenInsertionPoints: &partialFraction)
if characterIndex < textStorage.length {
if characterIndex < textStorage.length && partialFraction < 1 {
var range = NSRange()
if let link = textStorage.attribute(.link, at: characterIndex, longestEffectiveRange: &range, in: textStorage.fullRange) as? URL {
return (link, range)