Fix mentions + search bug

This commit is contained in:
nielsandriesse 2020-06-20 10:15:07 +10:00
parent 8470e1b265
commit 58fbd16286

View file

@ -716,7 +716,7 @@ NS_ASSUME_NONNULL_BEGIN
NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:[NSRegularExpression escapedPatternForString:searchableText] options:NSRegularExpressionCaseInsensitive error:&error];
OWSAssertDebug(error == nil);
for (NSTextCheckingResult *match in
[regex matchesInString:text options:NSMatchingWithoutAnchoringBounds range:NSMakeRange(0, text.length)]) {
[regex matchesInString:attributedText.string options:NSMatchingWithoutAnchoringBounds range:NSMakeRange(0, attributedText.string.length)]) {
OWSAssertDebug(match.range.length >= ConversationSearchController.kMinimumSearchTextLength);
UIColor *highlightColor;
if (LKAppModeUtilities.isLightMode) {
@ -724,6 +724,7 @@ NS_ASSUME_NONNULL_BEGIN
} else {
highlightColor = UIColor.whiteColor;
}
if (match.range.location + match.range.length > attributedText.length) { continue; }
[attributedText addAttribute:NSBackgroundColorAttributeName value:highlightColor range:match.range];
[attributedText addAttribute:NSForegroundColorAttributeName value:UIColor.blackColor range:match.range];
}