aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-08-07 23:57:16 +0000
committerrowanbeentje <rowan@beent.je>2009-08-07 23:57:16 +0000
commit2297b13252ee7149606ecd4544898614f0ac9298 (patch)
treee9d704588859ba7b18a783f5ae214052d68fa8bf /Source/CMTextView.m
parent67a72bc3a598528f9d45010716df3554dd882241 (diff)
downloadsequelpro-2297b13252ee7149606ecd4544898614f0ac9298.tar.gz
sequelpro-2297b13252ee7149606ecd4544898614f0ac9298.tar.bz2
sequelpro-2297b13252ee7149606ecd4544898614f0ac9298.zip
Merge in recent fixes from trunk for 0.9.6 release:
- r1145 (Custom Query completion fixes) - r1148 (CSV file import reload bugfix) - Parts of r1150 (history navigation no longer generates invalid states) - r1172 (Add to favorites and favorites saving fixes)
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m30
1 files changed, 10 insertions, 20 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 2ce6022d..45c7f0df 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -121,6 +121,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
* the set of unique words, SQL keywords, user-defined funcs/procs, tables etc.
* NSDic key "display" := the displayed and to be inserted word
* NSDic key "image" := an image to be shown left from "display" (optional)
+ *
+ * [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"display", @"`foo`", @"insert", @"func-small", @"image", nil]
*/
- (NSArray *)suggestionsForSQLCompletionWith:(NSString *)currentWord dictMode:(BOOL)isDictMode
{
@@ -183,25 +185,18 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
}
- // Add predefined keywords
if(!isDictMode) {
- // [possibleCompletions addObjectsFromArray:[self keywords]];
- NSString *s;
- enumerate([self keywords], s)
+
+ // Add predefined keywords
+ for (id s in [self keywords])
[possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"dummy-small", @"image", nil]];
- }
-
- // Add predefined functions
- if(!isDictMode) {
- // [possibleCompletions addObjectsFromArray:[self functions]];
- NSString *s;
- enumerate([self functions], s)
+ // Add predefined functions
+ for (id s in [self functions])
[possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"func-small", @"image", nil]];
}
-
- // Build array of dictionaries as e.g.:
- // [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"display", @"`foo`", @"insert", @"func-small", @"image", nil]
+
+ // Make suggestions unique
for(id suggestion in possibleCompletions)
if(![compl containsObject:suggestion])
[compl addObject:suggestion];
@@ -912,12 +907,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
if(![[[self textStorage] attribute:kBTQuote atIndex:charRange.location effectiveRange:nil] isEqualToString:kBTQuoteValue] )
{
// Only parse for words if text size is less than 6MB
- // if([[self string] length]<6000000)
- // {
- // NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()\"'`-!;=+|?:~@"];
- // NSArray *textViewWords = [[self string] componentsSeparatedByCharactersInSet:separators];
- // [possibleCompletions addObjectsFromArray:textViewWords];
- // }
if([[self string] length]<6000000)
{
NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()[]{}\"'`-!;=+|?:~@"];
@@ -927,6 +916,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
[possibleCompletions addObjectsFromArray:[self keywords]];
+ [possibleCompletions addObjectsFromArray:[self functions]];
}
// Check for possible completions