Ensure that mention behavior is consistent cross-platform

This commit is contained in:
Niels Andriesse 2019-10-10 16:30:12 +11:00
parent 8264191ead
commit 966748ed1b
2 changed files with 2 additions and 4 deletions

View file

@ -709,7 +709,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *text = displayableText.displayText;
NSError *error1;
NSRegularExpression *regex1 = [[NSRegularExpression alloc] initWithPattern:@"@\\w*" options:0 error:&error1];
NSRegularExpression *regex1 = [[NSRegularExpression alloc] initWithPattern:@"@[0-9a-fA-F]*" options:0 error:&error1];
OWSAssertDebug(error1 == nil);
NSSet<NSString *> *knownUserIDs = LKAPI.userIDCache[thread.uniqueId];
NSMutableArray<NSValue *> *mentions = [NSMutableArray new];

View file

@ -3773,13 +3773,11 @@ typedef enum : NSUInteger {
[self.typingIndicators didStartTypingOutgoingInputInThread:self.thread];
NSUInteger currentEndIndex = textView.text.length - 1;
unichar lastCharacter = [textView.text characterAtIndex:currentEndIndex];
NSMutableCharacterSet *allowedCharacters = NSMutableCharacterSet.lowercaseLetterCharacterSet;
[allowedCharacters formUnionWithCharacterSet:NSCharacterSet.uppercaseLetterCharacterSet];
if (lastCharacter == '@') {
NSArray<NSString *> *userIDs = [LKAPI getUserIDsFor:@"" in:self.thread.uniqueId];
self.mentionStartIndex = (NSInteger)currentEndIndex + 1;
[self.inputToolbar showUserSelectionViewFor:userIDs in:self.thread];
} else if (![allowedCharacters characterIsMember:lastCharacter]) {
} else if ([NSCharacterSet.whitespaceAndNewlineCharacterSet characterIsMember:lastCharacter]) {
self.mentionStartIndex = -1;
[self.inputToolbar hideUserSelectionView];
} else {