From bf0c12fc6ff0e7eb0ec2603da61a0100faedbc25 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 19 Apr 2010 09:00:13 +0000 Subject: - Tweak autocompletion on-delay-after-typing to no longer trigger on whitespace (as before) or brackets, semicolons, mathematical symbols, or commas --- Source/CMTextView.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Source') diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 0b2ca6d3..b9b280f3 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -518,7 +518,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) - (void) doAutoCompletion { - if(completionIsOpen || !self || ![self delegate]) return; // Cancel autocompletion trigger @@ -533,12 +532,16 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if(![self delegate] || ![[self delegate] isKindOfClass:[CustomQuery class]] || r.length || snippetControlCounter > -1) return; if(r.location) { - if([[[self textStorage] attribute:kQuote atIndex:r.location-1 effectiveRange:nil] isEqualToString:kQuoteValue]) - return; - if(![[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:[[self string] characterAtIndex:r.location-1]]) - // Suppress auto-completion if window isn't active anymore - if([[NSApp keyWindow] firstResponder] == self) - [self doCompletionByUsingSpellChecker:NO fuzzyMode:NO autoCompleteMode:YES]; + NSCharacterSet *ignoreCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"\"'`;,()[]{}=+/<> \t\n\r"]; + + // Check the previous character and don't autocomplete if the character is whitespace or certain types of punctuation + if ([ignoreCharacterSet characterIsMember:[[self string] characterAtIndex:r.location - 1]]) return; + + // Suppress auto-completion if the window isn't active anymore + if ([[NSApp keyWindow] firstResponder] != self) return; + + // Trigger the completion + [self doCompletionByUsingSpellChecker:NO fuzzyMode:NO autoCompleteMode:YES]; } } -- cgit v1.2.3