diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 7199f20867..5be302526b 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -860,7 +860,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { if let chatListSearchResult = chatListSearchResult { for range in chatListSearchResult.resultRanges { - composedString.addAttribute(.foregroundColor, value: theme.messageHighlightedTextColor, range: NSRange(range, in: chatListSearchResult.text)) + let stringRange = NSRange(range, in: chatListSearchResult.text) + if stringRange.location >= 0 && stringRange.location + stringRange.length <= composedString.length { + composedString.addAttribute(.foregroundColor, value: theme.messageHighlightedTextColor, range: stringRange) + } } }