Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,25 @@ - (void)processTruncatedAttributedText:(NSTextStorage *)textStorage
// Remove color attributes for truncated range
for (NSAttributedStringKey key in
@[ NSForegroundColorAttributeName, NSBackgroundColorAttributeName ]) {
[textStorage removeAttribute:key range:characterRange];
id attribute = [textStorage attribute:key
atIndex:characterRange.location - 1
effectiveRange:nil];
__block BOOL rangeAlreadyMatches = YES;
[textStorage enumerateAttribute:key
inRange:characterRange
options:0
usingBlock:^(id value, NSRange range, BOOL *stopEnumerating) {
BOOL isEqual = value == attribute ||
(value != nil && attribute != nil && [value isEqual:attribute]);
if (!isEqual) {
rangeAlreadyMatches = NO;
*stopEnumerating = YES;
}
}];
if (rangeAlreadyMatches) {
continue;
}
[textStorage removeAttribute:key range:characterRange];
if (attribute != nullptr) {
[textStorage addAttribute:key value:attribute range:characterRange];
}
Expand Down