Adium

Changeset 15830

Show
Ignore:
Timestamp:
04/19/2006 06:20:24 AM (3 years ago)
Author:
evands
Message:

Fixed an edge case with smiley parsing: If a smiley is at the beginning or end of the line after trimming whitespace it should be displayed graphically. This check is done last because -[NSString stringByTrimmingCharactersInSet:] is more expensive than other things done for the emoticon.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/AIEmoticonController.m

    r15825 r15830  
    281281                                         (nextCharacter == '\"') || (nextCharacter == '\''))) { 
    282282                                        acceptable = YES; 
     283                                } 
     284                        } 
     285                        if (!acceptable) { 
     286                                /* If the emoticon would end the string except for whitespace or newlines at the end, or it begins the string after removing 
     287                                 * whitespace or newlines at the beginning, it is acceptable even if the previous conditions weren't met. 
     288                                 */ 
     289                                NSString        *trimmedString = [messageString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 
     290                                unsigned int trimmedLength = [trimmedString length]; 
     291                                if ([trimmedString length] == (originalEmoticonLocation + textLength)) { 
     292                                        acceptable = YES; 
     293                                } else if ((originalEmoticonLocation - (messageStringLength - trimmedLength)) == 0) { 
     294                                        acceptable = YES;                                        
    283295                                } 
    284296                        }