Browse files

No need to update the output on the fly – the search is massively fas…

…ter if you don't.
  • Loading branch information...
1 parent 4ac585b commit eb056ea14512456d0b5f2102f3984be0222fa0d1 @beelsebob committed Apr 12, 2013
Showing with 6 additions and 14 deletions.
  1. +6 −14 Stash/STAMainWindowController.m
View
20 Stash/STAMainWindowController.m
@@ -17,7 +17,7 @@ @interface STAMainWindowController () <NSTableViewDelegate, NSTableViewDataSourc
@property (copy) NSString *currentSearchString;
@property (strong) NSMutableArray *results;
-@property (strong) NSMutableArray *sortedResults;
+@property (strong) NSArray *sortedResults;
@property (assign, getter=isFindUIShowing) BOOL findUIShowing;
@property (weak) NSSearchField *selectedSearchField;
@@ -199,6 +199,11 @@ - (void)searchDocSet:(STADocSet *)docSet forString:(NSString *)searchString
{
[self setResultNeedsDisplay:symbol forSearchString:searchString];
}];
+ dispatch_sync(dispatch_get_main_queue(), ^()
+ {
+ [self setSortedResults:[[self results] sortedArrayUsingSelector:@selector(compare:)]];
+ [[self resultsTable] reloadData];
+ });
}
}
@@ -209,19 +214,6 @@ - (void)setResultNeedsDisplay:(STASymbol *)symbol forSearchString:(NSString *)se
if ([searchString isEqualToString:[self currentSearchString]])
{
[[self results] addObject:symbol];
- NSUInteger insertionIndex = [[self sortedResults] indexOfObject:symbol
- inSortedRange:NSMakeRange(0, [[self sortedResults] count])
- options:NSBinarySearchingInsertionIndex
- usingComparator:^ NSComparisonResult (STASymbol *a, STASymbol *b)
- {
- return [a compare:b];
- }];
- [[self sortedResults] insertObject:symbol atIndex:insertionIndex];
- [[self resultsTable] insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:insertionIndex] withAnimation:0];
- if ([[self resultsTable] selectedRow] != 0)
- {
- [[self resultsTable] selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
- }
}
});
}

0 comments on commit eb056ea

Please sign in to comment.