aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-04-19 09:00:13 +0000
committerrowanbeentje <rowan@beent.je>2010-04-19 09:00:13 +0000
commitbf0c12fc6ff0e7eb0ec2603da61a0100faedbc25 (patch)
tree5fdcdacfc2445a7744fbd823093c31821f9c7589 /Source/CMTextView.m
parente1ecf814f0626757c0a7fca0beb78db2ec5405be (diff)
downloadsequelpro-bf0c12fc6ff0e7eb0ec2603da61a0100faedbc25.tar.gz
sequelpro-bf0c12fc6ff0e7eb0ec2603da61a0100faedbc25.tar.bz2
sequelpro-bf0c12fc6ff0e7eb0ec2603da61a0100faedbc25.zip
- Tweak autocompletion on-delay-after-typing to no longer trigger on whitespace (as before) or brackets, semicolons, mathematical symbols, or commas
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m17
1 files changed, 10 insertions, 7 deletions
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];
}
}