diff options
author | avenjamin <avenjamin@gmail.com> | 2009-03-05 02:39:03 +0000 |
---|---|---|
committer | avenjamin <avenjamin@gmail.com> | 2009-03-05 02:39:03 +0000 |
commit | 0ebdbeb0201580e5abcded23dd37b6b3516cbb84 (patch) | |
tree | 2d42946e375f2b9c4ae64afaa6179d96cabbea8f /Source/CMTextView.m | |
parent | cdd06f0fac3bf238d62e359419ef53b8098a5b62 (diff) | |
download | sequelpro-0ebdbeb0201580e5abcded23dd37b6b3516cbb84.tar.gz sequelpro-0ebdbeb0201580e5abcded23dd37b6b3516cbb84.tar.bz2 sequelpro-0ebdbeb0201580e5abcded23dd37b6b3516cbb84.zip |
Added column names to completion list for for currently selected table.
Diffstat (limited to 'Source/CMTextView.m')
-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; |