Skip to content

Commit 0b63765

Browse files
committed
Merge branch 'refs/heads/filtering_File_Browser'
2 parents a7e89b7 + afc0fdd commit 0b63765

File tree

5 files changed

+368
-190
lines changed

5 files changed

+368
-190
lines changed

PBGitHistoryController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
IBOutlet PBRefController *refController;
2828
IBOutlet NSSearchField *searchField;
2929
IBOutlet NSArrayController* commitController;
30+
IBOutlet NSSearchField *filesSearchField;
3031
IBOutlet NSTreeController* treeController;
3132
IBOutlet NSOutlineView* fileBrowser;
3233
NSArray *currentFileBrowserSelectionPath;
@@ -94,6 +95,7 @@
9495
// Find/Search methods
9596
- (IBAction)selectNext:(id)sender;
9697
- (IBAction)selectPrevious:(id)sender;
98+
- (IBAction) updateSearch:(id) sender;
9799

98100
- (void) copyCommitInfo;
99101
- (void) copyCommitSHA;

PBGitHistoryController.m

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
232232
{
233233
if ([(NSString *)context isEqualToString: @"commitChange"]) {
234234
[self updateKeys];
235-
//[self restoreFileBrowserSelection];
235+
[self restoreFileBrowserSelection];
236+
[self updateSearch:filesSearchField];
236237
}else if ([(NSString *)context isEqualToString: @"treeChange"]) {
237238
[self updateQuicklookForce: NO];
238239
[self saveFileBrowserSelection];
@@ -811,6 +812,32 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCe
811812
NSImage *image = [workspace iconForFile:path];
812813
[image setSize:NSMakeSize(15, 15)];
813814
[cell setImage:image];
815+
816+
NSColor *textColor = [NSColor blackColor];
817+
if ([object filterPredicate] && !([[filesSearchField stringValue] length] > 0 && [[object filterPredicate] evaluateWithObject:object])) {
818+
textColor = [NSColor lightGrayColor];
819+
}
820+
821+
822+
[cell setTextColor:textColor];
823+
}
824+
825+
#pragma mark -
826+
827+
- (IBAction) updateSearch:(NSSearchField *) sender {
828+
static NSPredicate *predicateTemplate = nil;
829+
if (!predicateTemplate) {
830+
predicateTemplate = [NSPredicate predicateWithFormat:@"path CONTAINS[c] $SEARCH_STRING"];
831+
}
832+
833+
NSString *searchString = [sender stringValue];
834+
NSPredicate *predicate = nil;
835+
if ([searchString length] > 0) {
836+
predicate = [predicateTemplate predicateWithSubstitutionVariables:
837+
[NSDictionary dictionaryWithObject:searchString forKey:@"SEARCH_STRING"]];
838+
}
839+
[gitTree setFilterPredicate:predicate];
840+
[treeController setContent:gitTree.filteredChildren];
814841
}
815842

816843
@end

0 commit comments

Comments
 (0)