Merge branch 'mkirk/highlight-pattern' into release/2.38.0

pull/2/head
Michael Kirk 6 years ago
commit a98bfee645

@ -82,11 +82,12 @@ extension ConversationSearchController: UISearchResultsUpdating {
public func updateSearchResults(for searchController: UISearchController) { public func updateSearchResults(for searchController: UISearchController) {
Logger.verbose("searchBar.text: \( searchController.searchBar.text ?? "<blank>")") Logger.verbose("searchBar.text: \( searchController.searchBar.text ?? "<blank>")")
guard let searchText = searchController.searchBar.text?.stripped else { guard let rawSearchText = searchController.searchBar.text?.stripped else {
self.resultsBar.updateResults(resultSet: nil) self.resultsBar.updateResults(resultSet: nil)
self.delegate?.conversationSearchController(self, didUpdateSearchResults: nil) self.delegate?.conversationSearchController(self, didUpdateSearchResults: nil)
return return
} }
let searchText = FullTextSearchFinder.normalize(text: rawSearchText)
BenchManager.startEvent(title: "Conversation Search", eventId: searchText) BenchManager.startEvent(title: "Conversation Search", eventId: searchText)
guard searchText.count >= ConversationSearchController.kMinimumSearchTextLength else { guard searchText.count >= ConversationSearchController.kMinimumSearchTextLength else {

@ -708,8 +708,10 @@ NS_ASSUME_NONNULL_BEGIN
initWithString:text initWithString:text
attributes:@{ NSFontAttributeName : font, NSForegroundColorAttributeName : textColor }]; attributes:@{ NSFontAttributeName : font, NSForegroundColorAttributeName : textColor }];
if (searchText.length >= ConversationSearchController.kMinimumSearchTextLength) { if (searchText.length >= ConversationSearchController.kMinimumSearchTextLength) {
NSString *searchableText = [FullTextSearchFinder normalizeWithText:searchText];
NSError *error; NSError *error;
NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:searchText NSRegularExpression *regex =
[[NSRegularExpression alloc] initWithPattern:[NSRegularExpression escapedPatternForString:searchableText]
options:NSRegularExpressionCaseInsensitive options:NSRegularExpressionCaseInsensitive
error:&error]; error:&error];
OWSAssertDebug(error == nil); OWSAssertDebug(error == nil);

@ -4210,7 +4210,16 @@ typedef enum : NSUInteger {
// restore first responder to VC // restore first responder to VC
[self becomeFirstResponder]; [self becomeFirstResponder];
if (@available(iOS 10, *)) {
[self reloadInputViews];
} else {
// We want to change the inputAccessoryView from SearchResults -> MessageInput
// reloading too soon on an old iOS9 device caused the inputAccessoryView to go from
// SearchResults -> MessageInput -> SearchResults
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self reloadInputViews]; [self reloadInputViews];
});
}
} }
#pragma mark ConversationSearchControllerDelegate #pragma mark ConversationSearchControllerDelegate

@ -138,6 +138,7 @@ public class FullTextSearchFinder: NSObject {
// This is a hot method, especially while running large migrations. // This is a hot method, especially while running large migrations.
// Changes to it should go through a profiler to make sure large migrations // Changes to it should go through a profiler to make sure large migrations
// aren't adversely affected. // aren't adversely affected.
@objc
public class func normalize(text: String) -> String { public class func normalize(text: String) -> String {
// 1. Filter out invalid characters. // 1. Filter out invalid characters.
let filtered = text.removeCharacters(characterSet: charactersToRemove) let filtered = text.removeCharacters(characterSet: charactersToRemove)

Loading…
Cancel
Save