Skip to content

Commit 513e6b1

Browse files
committed
Ignore task termination when performing searches
When typing quickly, it could happen that two task would be start, and the second would terminate the first, triggering the bug. Fixes #123
1 parent 7ab0a9c commit 513e6b1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Classes/Controllers/PBHistorySearchController.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import "PBGitDefaults.h"
1616
#import "PBCommitList.h"
1717
#import "PBGitCommit.h"
18+
#import "PBError.h"
1819

1920
@interface PBHistorySearchController ()
2021

@@ -420,8 +421,20 @@ - (void)startBackgroundSearch
420421
}
421422

422423
backgroundSearchTask = [historyController.repository taskWithArguments:searchArguments];
423-
[backgroundSearchTask performTaskWithCompletionHandler:^(NSData * _Nullable readData, NSError * _Nullable error) {
424+
[backgroundSearchTask performTaskWithCompletionHandler:^(NSData *readData, NSError *taskError) {
425+
if (taskError.domain == PBTaskErrorDomain && taskError.code == PBTaskCaughtSignalError) {
426+
/* Silently ignore task termination */
427+
return;
428+
}
429+
424430
if (!readData) {
431+
[self clearProgressIndicator];
432+
NSString *desc = NSLocalizedString(@"Search failed", @"Search Controller - Background search failed error description");
433+
NSString *reason = NSLocalizedString(@"The search for \"%@\" failed.", @"Search Controller - Background search failed error reason");
434+
reason = [NSString stringWithFormat:reason, searchString];
435+
NSError *error = [NSError pb_errorWithDescription:desc
436+
failureReason:reason
437+
underlyingError:taskError];
425438
[historyController.windowController showErrorSheet:error];
426439
return;
427440
}

0 commit comments

Comments
 (0)