Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74c01ee

Browse files
author
Ignacio Romero Zurbuchen
committed
Uses NSCharacterSet to detect a whitespace instead
1 parent 69ca754 commit 74c01ee

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Source/SLKTextInput+Extension.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ - (NSString *)wordAtRange:(NSRange)range rangeInText:(NSRangePointer)rangePointe
8888

8989
if (location > 0) {
9090
NSString *characterBeforeCursor = [text substringWithRange:NSMakeRange(location-1, 1)];
91+
NSRange whitespaceRange = [characterBeforeCursor rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]];
9192

92-
if ([characterBeforeCursor isEqualToString:@" "]) {
93+
if (whitespaceRange.length == 1) {
9394
// At the start of a word, just use the word behind the cursor for the current word
9495
*rangePointer = NSMakeRange(location, rightPart.length);
9596

0 commit comments

Comments
 (0)