optonaut/ActiveLabel.swift

Range is bigger than it should.

brunomunizaf opened this issue · 2 comments

It seems that the range is bigger than it should.

Screen Shot 2020-03-28 at 4 26 52 AM

        textLabel.enabledTypes = [.url]
        textLabel.URLColor = .white

        textLabel.configureLinkAttribute = { (type, attributes, isSelected) in
            var atts = attributes
            atts[NSAttributedString.Key.underlineStyle] = NSUnderlineStyle.single.rawValue
            return atts
        }

Solved by setting value to .urlMaximumLength, which leads me to think that

guard let maxLength = maximumLength, word.count > maxLength else {
    let range = maximumLength == nil ? match.range : (text as NSString).range(of: word)
    let element = ActiveElement.create(with: type, text: word)
    elements.append((range, element, type))
    continue
}

(ActiveBuilder.swift 37:42) might be the problem.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.