aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CMTextView.h3
-rw-r--r--Source/CMTextView.m13
-rw-r--r--Source/SPNarrowDownCompletion.m10
3 files changed, 22 insertions, 4 deletions
diff --git a/Source/CMTextView.h b/Source/CMTextView.h
index 224349e3..6e51d47f 100644
--- a/Source/CMTextView.h
+++ b/Source/CMTextView.h
@@ -64,6 +64,8 @@
BOOL completionIsOpen;
BOOL completionWasReinvokedAutomatically;
+ BOOL completionWasRefreshed;
+ BOOL completionFuzzyMode;
NSUInteger completionParseRangeLocation;
NSColor *queryHiliteColor;
@@ -120,6 +122,7 @@
- (void) setConnection:(MCPConnection *)theConnection withVersion:(NSInteger)majorVersion;
- (void) doCompletionByUsingSpellChecker:(BOOL)isDictMode fuzzyMode:(BOOL)fuzzySearch autoCompleteMode:(BOOL)autoCompleteMode;
- (void) doAutoCompletion;
+- (void) refreshCompletion;
- (NSArray *)suggestionsForSQLCompletionWith:(NSString *)currentWord dictMode:(BOOL)isDictMode browseMode:(BOOL)dbBrowseMode withTableName:(NSString*)aTableName withDbName:(NSString*)aDbName;
- (void) selectCurrentQuery;
- (void) processMirroredSnippets;
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index fae2554a..0a753007 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -131,6 +131,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
mirroredCounter = -1;
completionIsOpen = NO;
isProcessingMirroredSnippets = NO;
+ completionWasRefreshed = NO;
lineNumberView = [[NoodleLineNumberView alloc] initWithScrollView:scrollView];
[scrollView setVerticalRulerView:lineNumberView];
@@ -542,6 +543,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
+- (void) refreshCompletion
+{
+ if(completionWasRefreshed) return;
+ completionWasRefreshed = YES;
+ [self doCompletionByUsingSpellChecker:NO fuzzyMode:completionFuzzyMode autoCompleteMode:NO];
+}
+
- (void) doCompletionByUsingSpellChecker:(BOOL)isDictMode fuzzyMode:(BOOL)fuzzySearch autoCompleteMode:(BOOL)autoCompleteMode
{
@@ -556,6 +564,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
[self breakUndoCoalescing];
+
+ // Remember state for refreshCompletion
+ completionFuzzyMode = fuzzySearch;
NSUInteger caretPos = NSMaxRange([self selectedRange]);
@@ -1999,7 +2010,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
if ([theEvent keyCode] == 53 && [self isEditable]){ // ESC key for internal completion
[self setCompletionWasReinvokedAutomatically:NO];
-
+ completionWasRefreshed = NO;
// Cancel autocompletion trigger
if([prefs boolForKey:SPCustomQueryAutoComplete])
[NSObject cancelPreviousPerformRequestsWithTarget:self
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index 1e6a9247..3de3067f 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -171,7 +171,7 @@
[stateTimer release];
stateTimer = nil;
if(syncArrowImages) [syncArrowImages release];
- [self performSelectorOnMainThread:@selector(reInvokeCompletion) withObject:nil waitUntilDone:NO];
+ [self performSelectorOnMainThread:@selector(reInvokeCompletion) withObject:nil waitUntilDone:YES];
closeMe = YES;
return;
}
@@ -184,10 +184,14 @@
- (void)reInvokeCompletion
{
+ if(stateTimer) {
+ [stateTimer invalidate];
+ [stateTimer release];
+ stateTimer = nil;
+ }
[theView setCompletionIsOpen:NO];
[self close];
- usleep(70);
- [theView doCompletionByUsingSpellChecker:dictMode fuzzyMode:fuzzyMode autoCompleteMode:NO];
+ [theView performSelector:@selector(refreshCompletion) withObject:nil afterDelay:0.0];
}
- (id)initWithItems:(NSArray*)someSuggestions alreadyTyped:(NSString*)aUserString staticPrefix:(NSString*)aStaticPrefix