From bb655eefa290342fc30fd3deaad589e84f134c6d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 24 Apr 2024 16:42:24 -0500 Subject: [PATCH] ensure color range Signed-off-by: Matt Bruce --- VDS/Components/Label/Attributes/ColorLabelAttribute.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/VDS/Components/Label/Attributes/ColorLabelAttribute.swift b/VDS/Components/Label/Attributes/ColorLabelAttribute.swift index 0e6dd653..fd1b9a21 100644 --- a/VDS/Components/Label/Attributes/ColorLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/ColorLabelAttribute.swift @@ -34,10 +34,9 @@ public struct ColorLabelAttribute: LabelAttributeModel { var colorRange = range if length == 0 && location == 0 { colorRange = .init(location: location, length: attributedString.length) - if !attributedString.isValid(range: colorRange) { return } - } else { - guard isValidRange(on: attributedString) else { return } } + + if !attributedString.isValid(range: colorRange) { return } let attributeKey = isForegroundColor ? NSAttributedString.Key.foregroundColor : NSAttributedString.Key.backgroundColor attributedString.removeAttribute(attributeKey, range: colorRange)