aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-04-07 16:04:35 +0000
committerBibiko <bibiko@eva.mpg.de>2010-04-07 16:04:35 +0000
commitc58984f7fb82a089bdc508f0bdf7dc6df89cb979 (patch)
treea38500ce609ad7f363202779ffec2d43d29b84e1 /Source
parentb5ade8a12cea34738d89508cb04d0cdfaf1174a9 (diff)
downloadsequelpro-c58984f7fb82a089bdc508f0bdf7dc6df89cb979.tar.gz
sequelpro-c58984f7fb82a089bdc508f0bdf7dc6df89cb979.tar.bz2
sequelpro-c58984f7fb82a089bdc508f0bdf7dc6df89cb979.zip
Tried to fine-tune the auto-completion behaviour esp. for automatically inserted suggestions and increased the minimum auto-complete delay to 0.5s since below that a fight between computer speed and user typing speed could occur.
This addresses i625.
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m3
-rw-r--r--Source/SPNarrowDownCompletion.h2
-rw-r--r--Source/SPNarrowDownCompletion.m55
3 files changed, 57 insertions, 3 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 0a753007..75839bc8 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -791,8 +791,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[completionPopUp setCaretPos:pos];
[completionPopUp orderFront:self];
- if(!autoCompleteMode)
- [completionPopUp insertCommonPrefix];
+ [completionPopUp insertCommonPrefix];
}
diff --git a/Source/SPNarrowDownCompletion.h b/Source/SPNarrowDownCompletion.h
index fc8bd942..032aef24 100644
--- a/Source/SPNarrowDownCompletion.h
+++ b/Source/SPNarrowDownCompletion.h
@@ -50,6 +50,8 @@
BOOL autoCompletionMode;
BOOL oneColumnMode;
BOOL isQueryingDatabaseStructure;
+ BOOL commonPrefixWasInsertedByAutoComplete;
+ NSMutableString *originalFilterString;
NSInteger backtickMode;
NSFont *tableFont;
NSRange theCharRange;
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index 3de3067f..84568019 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -118,7 +118,10 @@
filtered = nil;
spaceCounter = 0;
currentSyncImage = 0;
+ commonPrefixWasInsertedByAutoComplete = NO;
prefs = [NSUserDefaults standardUserDefaults];
+ originalFilterString = [[NSMutableString alloc] init];
+ [originalFilterString setString:@""];
tableFont = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:SPCustomQueryEditorFont]];
[self setupInterface];
@@ -146,7 +149,7 @@
[staticPrefix release];
[mutablePrefix release];
[textualInputCharacters release];
-
+ [originalFilterString release];
if(suggestions) [suggestions release];
if (filtered) [filtered release];
@@ -210,6 +213,10 @@
[mutablePrefix appendString:aUserString];
autoCompletionMode = autoComplete;
+
+ if(autoCompletionMode)
+ [originalFilterString appendString:aUserString];
+
oneColumnMode = oneColumn;
isQueryingDatabaseStructure = isQueryingDBStructure;
@@ -765,6 +772,16 @@
// e.g. for US keyboard "⌥u a" to insert ä
if (([event modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) == NSAlternateKeyMask || [[event characters] length] == 0)
{
+ if(autoCompletionMode) {
+ if(commonPrefixWasInsertedByAutoComplete) {
+ [theView setSelectedRange:theCharRange];
+ [theView insertText:originalFilterString];
+ [NSApp sendEvent:event];
+ [theView setCompletionIsOpen:NO];
+ [self close];
+ break;
+ }
+ }
[NSApp sendEvent: event];
if(commaInsertionMode)
@@ -787,6 +804,15 @@
[theTableView setBackgroundColor:[NSColor colorWithCalibratedRed:0.9f green:0.9f blue:0.9f alpha:1.0f]];
[self filter];
} else {
+ if(autoCompletionMode) {
+ if(commonPrefixWasInsertedByAutoComplete) {
+ [theView setSelectedRange:theCharRange];
+ [theView insertText:originalFilterString];
+ }
+ [theView setCompletionIsOpen:NO];
+ [self close];
+ break;
+ }
if(cursorMovedLeft) [theView performSelector:@selector(moveRight:)];
break;
}
@@ -797,6 +823,14 @@
}
else if(key == NSBackspaceCharacter || key == NSDeleteCharacter)
{
+ if(autoCompletionMode) {
+ if(commonPrefixWasInsertedByAutoComplete) {
+ [theView setSelectedRange:theCharRange];
+ [theView insertText:originalFilterString];
+ }
+ [NSApp sendEvent:event];
+ break;
+ }
[NSApp sendEvent:event];
if([mutablePrefix length] == 0 || commaInsertionMode)
break;
@@ -809,6 +843,18 @@
}
else if([textualInputCharacters characterIsMember:key])
{
+
+ if(autoCompletionMode) {
+ [theView setCompletionIsOpen:NO];
+ [self close];
+ if(commonPrefixWasInsertedByAutoComplete) {
+ [theView setSelectedRange:theCharRange];
+ [theView insertText:originalFilterString];
+ }
+ [NSApp sendEvent:event];
+ return;
+ }
+
[NSApp sendEvent:event];
if(commaInsertionMode)
@@ -837,6 +883,12 @@
} else {
[NSApp sendEvent:event];
if(!NSPointInRect([NSEvent mouseLocation], [self frame])) {
+ if(autoCompletionMode) {
+ if(commonPrefixWasInsertedByAutoComplete) {
+ [theView setSelectedRange:theCharRange];
+ [theView insertText:originalFilterString];
+ }
+ }
if(cursorMovedLeft) [theView performSelector:@selector(moveRight:)];
break;
}
@@ -887,6 +939,7 @@
theCharRange.length += [toInsert length];
theParseRange.length += [toInsert length];
[theView insertText:[toInsert lowercaseString]];
+ commonPrefixWasInsertedByAutoComplete = YES;
[self checkSpaceForAllowedCharacter];
}
}