From d0201d5ff680a05f265db025c53cc4e4fe407c7e Mon Sep 17 00:00:00 2001
From: Toni Sevener <tsevener@wikimedia.org>
Date: Fri, 15 Dec 2023 08:50:16 -0600
Subject: [PATCH] Fix bug

---
 .../WKSourceEditorFormatterReference.m           | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/Components/Sources/ComponentsObjC/WKSourceEditorFormatterReference.m b/Components/Sources/ComponentsObjC/WKSourceEditorFormatterReference.m
index ad6c18b34c5..f427197c3b4 100644
--- a/Components/Sources/ComponentsObjC/WKSourceEditorFormatterReference.m
+++ b/Components/Sources/ComponentsObjC/WKSourceEditorFormatterReference.m
@@ -156,13 +156,21 @@ - (BOOL)attributedString:(NSMutableAttributedString *)attributedString isHorizon
        }
 
    } else {
+       __block NSRange unionRange = NSMakeRange(NSNotFound, 0);
        [attributedString enumerateAttributesInRange:range options:nil usingBlock:^(NSDictionary<NSAttributedStringKey,id> * _Nonnull attrs, NSRange loopRange, BOOL * _Nonnull stop) {
-               if ((attrs[WKSourceEditorCustomKeyContentReference] != nil) &&
-                   (loopRange.location == range.location && loopRange.length == range.length)) {
-                   isContentKey = YES;
-                   stop = YES;
+           if (attrs[WKSourceEditorCustomKeyContentReference] != nil) {
+               if (unionRange.location == NSNotFound) {
+                   unionRange = loopRange;
+               } else {
+                   unionRange = NSUnionRange(unionRange, loopRange);
                }
+               stop = YES;
+           }
        }];
+       
+        if (NSEqualRanges(unionRange, range)) {
+            isContentKey = YES;
+        }
    }
 
    return isContentKey;