mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Let Open Quickly… block main thread until open documents are loaded
This should ensure that ⌘T quickly followed by ↩ will always select the last document (as long as it is still open).
This commit is contained in:
@@ -486,15 +486,28 @@ static NSDictionary* globs_for_path (std::string const& path)
|
||||
[_searchResults removeAllObjects];
|
||||
}
|
||||
|
||||
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
__block BOOL didSignal = NO;
|
||||
|
||||
[OakDocumentController.sharedInstance enumerateDocumentsAtPath:path options:options usingBlock:^(OakDocument* document, BOOL* stop){
|
||||
@synchronized(_searchResults) {
|
||||
if(document.open == NO)
|
||||
{
|
||||
dispatch_semaphore_signal(sem);
|
||||
didSignal = YES;
|
||||
}
|
||||
|
||||
if(searchToken == _lastSearchToken)
|
||||
[_searchResults addObject:document];
|
||||
else *stop = YES;
|
||||
}
|
||||
}];
|
||||
|
||||
if(didSignal == NO)
|
||||
dispatch_semaphore_signal(sem);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if(searchToken == _lastSearchToken)
|
||||
{
|
||||
@@ -504,6 +517,9 @@ static NSDictionary* globs_for_path (std::string const& path)
|
||||
});
|
||||
});
|
||||
|
||||
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
|
||||
[self handleSearchResults:nil];
|
||||
|
||||
_pollInterval = 0.02;
|
||||
_pollTimer = [NSTimer scheduledTimerWithTimeInterval:_pollInterval target:self selector:@selector(handleSearchResults:) userInfo:nil repeats:NO];
|
||||
[_progressIndicator performSelector:@selector(startAnimation:) withObject:self afterDelay:0.2];
|
||||
|
||||
Reference in New Issue
Block a user