diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-04-06 18:13:31 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-04-06 18:13:31 +0000 |
commit | 5733c4492539c132dab6f11219803627c08465cd (patch) | |
tree | 737f63690fd54438ab747f1cd8f33ff3c4d68d1c | |
parent | 2b1c1fb175ef5702ee00e5285226e642039b4afd (diff) | |
download | sequelpro-5733c4492539c132dab6f11219803627c08465cd.tar.gz sequelpro-5733c4492539c132dab6f11219803627c08465cd.tar.bz2 sequelpro-5733c4492539c132dab6f11219803627c08465cd.zip |
• overlapping of completion windows after refreshing its content if db structure fetching was finished
- for some reasons it could happen that the timer? fires twice, to avoid this changed the re-invocation strategy
-rw-r--r-- | Source/CMTextView.h | 3 | ||||
-rw-r--r-- | Source/CMTextView.m | 13 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 10 |
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 |