27
27
#import " GIWindowController.h"
28
28
#import " XLFacilityMacros.h"
29
29
30
- @interface GIAdvancedCommitViewController () <GIDiffFilesViewControllerDelegate, GIDiffContentsViewControllerDelegate>
30
+ @interface GIAdvancedCommitViewController () <GIDiffFilesViewControllerDelegate, GIDiffContentsViewControllerDelegate, NSSearchFieldDelegate >
31
31
@property (nonatomic , weak ) IBOutlet GIColorView* workdirHeaderView;
32
32
@property (nonatomic , weak ) IBOutlet NSView * workdirFilesView;
33
33
@property (nonatomic , weak ) IBOutlet GIColorView* indexHeaderView;
@@ -37,6 +37,7 @@ @interface GIAdvancedCommitViewController () <GIDiffFilesViewControllerDelegate,
37
37
@property (nonatomic , weak ) IBOutlet NSButton * commitButton;
38
38
@property (nonatomic , weak ) IBOutlet NSButton * stageButton;
39
39
@property (nonatomic , weak ) IBOutlet NSButton * discardButton;
40
+ @property (nonatomic , weak ) IBOutlet NSTextField * searchTextField;
40
41
@end
41
42
42
43
@implementation GIAdvancedCommitViewController {
@@ -50,6 +51,23 @@ @implementation GIAdvancedCommitViewController {
50
51
BOOL _disableFeedback;
51
52
}
52
53
54
+ #pragma mark - Search
55
+ - (void )setupSearch {
56
+ [NSNotificationCenter .defaultCenter addObserver: self selector: @selector (textDidChange: ) name: NSTextDidChangeNotification object: nil ];
57
+ }
58
+
59
+ - (void )textDidChange : (NSNotification *)notification {
60
+ NSLog (@" NewValue: %@ " , self.searchTextField .stringValue );
61
+ NSString *text = self.searchTextField .stringValue ;
62
+ if ([@" " isEqualToString: text]) {
63
+ [self .repository updateFilePattern: nil ];
64
+ }
65
+ else {
66
+ [self .repository updateFilePattern: text];
67
+ }
68
+ }
69
+
70
+ #pragma mark - View Lifecycle
53
71
- (void )loadView {
54
72
[super loadView ];
55
73
@@ -75,6 +93,7 @@ - (void)loadView {
75
93
[_diffContentsView replaceWithView: _diffContentsViewController.view];
76
94
77
95
self.messageTextView .string = @" " ;
96
+ [self setupSearch ];
78
97
}
79
98
80
99
- (void )viewWillAppear {
@@ -104,6 +123,7 @@ - (void)viewDidDisappear {
104
123
self.repository .statusMode = kGCLiveRepositoryStatusMode_Disabled ;
105
124
}
106
125
126
+ #pragma mark - Repository Handling
107
127
- (void )repositoryStatusDidUpdate {
108
128
[super repositoryStatusDidUpdate ];
109
129
@@ -157,6 +177,14 @@ - (void)_reloadContents {
157
177
[self _updateCommitButton ];
158
178
}
159
179
180
+ - (void )didCreateCommit : (GCCommit*)commit {
181
+ [super didCreateCommit: commit];
182
+
183
+ _indexActive = NO ;
184
+ [self .view.window makeFirstResponder: _workdirFilesViewController.preferredFirstResponder];
185
+ }
186
+
187
+ #pragma mark - First Responder
160
188
// We can't use the default implementation since we need a dynamic first-responder
161
189
- (NSView *)preferredFirstResponder {
162
190
if (_indexStatus.deltas .count && !_workdirStatus.deltas .count ) {
@@ -165,13 +193,6 @@ - (NSView*)preferredFirstResponder {
165
193
return _workdirFilesViewController.preferredFirstResponder ;
166
194
}
167
195
168
- - (void )didCreateCommit : (GCCommit*)commit {
169
- [super didCreateCommit: commit];
170
-
171
- _indexActive = NO ;
172
- [self .view.window makeFirstResponder: _workdirFilesViewController.preferredFirstResponder];
173
- }
174
-
175
196
#pragma mark - GIDiffFilesViewControllerDelegate
176
197
177
198
- (void )diffFilesViewControllerDidBecomeFirstResponder : (GIDiffFilesViewController*)controller {
0 commit comments