diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMTextView.m | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index bce2bd4a..7ca2f782 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -2,7 +2,7 @@ // CMTextView.m // sequel-pro // -// Created by Carsten BlŸm. +// Created by Carsten Blüm. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -34,11 +34,22 @@ NSString *partialString = [[self string] substringWithRange:charRange]; unsigned int partialLength = [partialString length]; id tableNames = [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"tables"]; + //unsigned int options = NSCaseInsensitiveSearch | NSAnchoredSearch; //NSRange partialRange = NSMakeRange(0, partialLength); + NSMutableArray *compl = [[NSMutableArray alloc] initWithCapacity:32]; - NSArray *possibleCompletions = [[tableNames arrayByAddingObjectsFromArray:[self keywords]] - arrayByAddingObjectsFromArray:textViewWords]; + + NSMutableArray *possibleCompletions = [NSMutableArray arrayWithArray:textViewWords]; + [possibleCompletions addObjectsFromArray:[self keywords]]; + [possibleCompletions addObjectsFromArray:tableNames]; + + // Add column names to completions list for currently selected table + if ([[[self window] delegate] table] != nil) { + id columnNames = [[[[self window] delegate] valueForKeyPath:@"tableDataInstance"] valueForKey:@"columnNames"]; + [possibleCompletions addObjectsFromArray:columnNames]; + } + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@ AND length > %d", partialString, partialLength]; NSArray *matchingCompletions = [[possibleCompletions filteredArrayUsingPredicate:predicate] sortedArrayUsingSelector:@selector(compare:)]; unsigned i, insindex; |