diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-01-20 12:11:09 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-01-20 12:11:09 +0000 |
commit | 38ed0a7356c24b2113e157fbec26004100b5f1e9 (patch) | |
tree | 5432a521262d0cd01ce25b12f5306b8234e8f81b /Source/CMTextView.m | |
parent | 4be3b84999e8ea31d47f3ec6b6926d1f13ec2ccf (diff) | |
download | sequelpro-38ed0a7356c24b2113e157fbec26004100b5f1e9.tar.gz sequelpro-38ed0a7356c24b2113e157fbec26004100b5f1e9.tar.bz2 sequelpro-38ed0a7356c24b2113e157fbec26004100b5f1e9.zip |
• completion
- auto-completes the common prefix of all suggestions - makes typing much more faster
- “ ” as allowed character to be typed for narrow-down the list is set automatically if at least one suggestion contains a “ ”
- fixed two tiny memory leaks
- fixed detecting db/table/field names containing ` as char
- removed ⇥ binding to complete the common prefix since it's done automatically
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r-- | Source/CMTextView.m | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 3b0cab17..6df89d03 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -206,7 +206,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if(dbs != nil && [dbs count]) { NSArray *allDbs = [dbs allKeys]; NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)]; - NSMutableArray *sortedDbs = [NSMutableArray array]; + NSMutableArray *sortedDbs = [[NSMutableArray array] autorelease]; [sortedDbs addObjectsFromArray:[allDbs sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]]; NSString *currentDb = nil; @@ -309,6 +309,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } } } + if(desc) [desc release]; } else { // Fallback for MySQL < 5 and if the data gathering is in progress if(mySQLmajorVersion > 4) @@ -364,7 +365,19 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) { // No completion for a selection (yet?) and if caret positiopn == 0 - if ([self selectedRange].length > 0 || ![self selectedRange].location) return; + if([self selectedRange].length > 0 || ![self selectedRange].location) return; + + NSInteger caretPos = [self selectedRange].location; + + // Check if caret is located after a ` - if so move caret inside + if([[self string] characterAtIndex:caretPos-1] == '`') { + if([[self string] length] > caretPos && [[self string] characterAtIndex:caretPos] == '`') { + ; + } else { + caretPos--; + [self setSelectedRange:NSMakeRange(caretPos, 0)]; + } + } NSString* filter; NSString* dbName = nil; @@ -395,7 +408,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) else currentDb = @""; - NSInteger caretPos = [self selectedRange].location; BOOL caretIsInsideBackticks = NO; // Is the caret inside backticks @@ -445,7 +457,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if(currentCharacter != '`' && currentCharacter != '.') break; if(currentCharacter == '`') { // ignore `` backticksCounter++; - start-=2; + start--; } } } @@ -542,7 +554,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [completionPopUp setCaretPos:pos]; [completionPopUp orderFront:self]; - + [completionPopUp insertCommonPrefix]; + } |