diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-04-07 16:04:35 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-04-07 16:04:35 +0000 |
commit | c58984f7fb82a089bdc508f0bdf7dc6df89cb979 (patch) | |
tree | a38500ce609ad7f363202779ffec2d43d29b84e1 /Source/SPNarrowDownCompletion.m | |
parent | b5ade8a12cea34738d89508cb04d0cdfaf1174a9 (diff) | |
download | sequelpro-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/SPNarrowDownCompletion.m')
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 55 |
1 files changed, 54 insertions, 1 deletions
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]; } } |