From 3a0743df3ea4272f90b65e43799f3d9d86ed415a Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 15 Jul 2009 10:12:34 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20dealloc=20of=20'suggestions'=20in?= =?UTF-8?q?=20SPNarrowDownCompletion=20=E2=80=A2=20deleted=20(void)paste?= =?UTF-8?q?=20hook=20from=20CMTextView=20(not=20needed=20anymore)=20?= =?UTF-8?q?=E2=80=A2=20decreased=20iteration=20cycles=20for=20'normal'=20c?= =?UTF-8?q?ompletion=20(ESC)=20by=20getting=20only=20the=20unique=20words?= =?UTF-8?q?=20from=20the=20current=20textView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.m | 26 +++++++++++--------------- Source/SPNarrowDownCompletion.m | 10 +++------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Source/CMTextView.m b/Source/CMTextView.m index dbd33342..ecca0721 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -915,12 +915,20 @@ 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,()\"'`-!;=+|?:~@"]; - NSArray *textViewWords = [[self string] componentsSeparatedByCharactersInSet:separators]; - [possibleCompletions addObjectsFromArray:textViewWords]; + NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()[]{}\"'`-!;=+|?:~@"]; + NSMutableArray *uniqueArray = [NSMutableArray array]; + [uniqueArray addObjectsFromArray:[[NSSet setWithArray:[[self string] componentsSeparatedByCharactersInSet:separators]] allObjects]]; + [possibleCompletions addObjectsFromArray:uniqueArray]; } + [possibleCompletions addObjectsFromArray:[self keywords]]; } @@ -945,18 +953,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } -/* - * Hook to invoke the auto-uppercasing of SQL keywords after pasting - */ -- (void)paste:(id)sender -{ - - [super paste:sender]; - // Invoke the auto-uppercasing of SQL keywords via an additional trigger - [self insertText:@""]; -} - - /* * List of keywords for autocompletion. If you add a keyword here, * it should also be added to the flex file SPEditorTokens.l diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index adadd902..e2a52882 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -110,8 +110,7 @@ [mutablePrefix release]; [textualInputCharacters release]; - // TODO: This may cause errors, I cannot see if it is always set up - only if !dictMode. - // [suggestions release]; + if(suggestions) [suggestions release]; if (filtered) [filtered release]; @@ -134,9 +133,7 @@ theView = aView; dictMode = mode; - if(dictMode) { - words = [NSArray arrayWithArray:suggestions]; - } else { + if(!dictMode) { suggestions = [someSuggestions retain]; words = nil; } @@ -236,8 +233,7 @@ NSArray* newFiltered; if([mutablePrefix length] > 0) { - if(dictMode) - { + if(dictMode) { newFiltered = [[NSSpellChecker sharedSpellChecker] completionsForPartialWordRange:NSMakeRange(0,[[self filterString] length]) inString:[self filterString] language:nil inSpellDocumentWithTag:0]; } else { NSPredicate* predicate; -- cgit v1.2.3