diff options
-rw-r--r-- | Source/SPNarrowDownCompletion.h | 1 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 16 |
2 files changed, 12 insertions, 5 deletions
diff --git a/Source/SPNarrowDownCompletion.h b/Source/SPNarrowDownCompletion.h index de4e7a06..96558b9d 100644 --- a/Source/SPNarrowDownCompletion.h +++ b/Source/SPNarrowDownCompletion.h @@ -58,6 +58,7 @@ id theView; NSInteger maxWindowWidth; + NSInteger spaceCounter; NSMutableCharacterSet* textualInputCharacters; } diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index a48aa204..3b108de6 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -109,6 +109,7 @@ textualInputCharacters = [[NSMutableCharacterSet alphanumericCharacterSet] retain]; caseSensitive = YES; filtered = nil; + spaceCounter = 0; tableFont = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:SPCustomQueryEditorFont]]; [self setupInterface]; @@ -369,12 +370,13 @@ - (void)checkSpaceForAllowedCharacter { [textualInputCharacters removeCharactersInString:@" "]; - for(id w in filtered){ - if([[w objectForKey:@"match"] ?: [w objectForKey:@"display"] rangeOfString:@" "].length) { - [textualInputCharacters addCharactersInString:@" "]; - break; + if(spaceCounter < 1) + for(id w in filtered){ + if([[w objectForKey:@"match"] ?: [w objectForKey:@"display"] rangeOfString:@" "].length) { + [textualInputCharacters addCharactersInString:@" "]; + break; + } } - } } // ==================== @@ -561,6 +563,7 @@ if([mutablePrefix length] == 0 || commaInsertionMode) break; + spaceCounter = 0; [mutablePrefix deleteCharactersInRange:NSMakeRange([mutablePrefix length]-1, 1)]; theCharRange.length--; theParseRange.length--; @@ -572,12 +575,15 @@ if(commaInsertionMode) break; + if([event keyCode] == 49) // space + spaceCounter++; [mutablePrefix appendString:[event characters]]; theCharRange.length++; theParseRange.length++; [self filter]; [self insertCommonPrefix]; + } else { |