Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improvement in parent directory search

  • Loading branch information...
commit f2177eeaf82bb005ec79ddceb484479f411e2218 1 parent c1bc22b
@jfmoy authored
Showing with 38 additions and 5 deletions.
  1. +38 −5 Classes/FRAAdvancedFindController.m
View
43 Classes/FRAAdvancedFindController.m
@@ -56,8 +56,14 @@ - (id)init
- (IBAction)findAction:(id)sender
{
+ FRAAdvancedFindScope searchScope = [[FRADefaults valueForKey:@"AdvancedFindScope"] integerValue];
+ NSArray *originalDocuments = nil;
+
+ if (searchScope == FRAParentDirectoryScope) {
+ originalDocuments = [NSArray arrayWithArray:[[FRACurrentProject documentsArrayController] arrangedObjects]];
+ }
+
NSString *searchString = [findSearchField stringValue];
- NSArray *originalDocuments = [[FRACurrentProject documentsArrayController] arrangedObjects];
[findResultsOutlineView setDelegate:nil];
@@ -191,11 +197,10 @@ - (IBAction)findAction:(id)sender
documentIndex--;
// Remove document if no results have been found into it and the document was not loaded before.
- FRAAdvancedFindScope searchScope = [[FRADefaults valueForKey:@"AdvancedFindScope"] integerValue];
- if (searchScope == FRAParentDirectoryScope) {
+ if ((searchScope == FRAParentDirectoryScope) && (originalDocuments != nil)) {
BOOL closing = YES;
- NSEnumerator *originalDocumentsEnumerator = [originalDocuments reverseObjectEnumerator];
+ NSEnumerator *originalDocumentsEnumerator = [originalDocuments objectEnumerator];
for (id originalDocument in originalDocumentsEnumerator) {
if (originalDocument == document) {
closing = NO;
@@ -236,6 +241,13 @@ - (IBAction)findAction:(id)sender
- (IBAction)replaceAction:(id)sender
{
+ FRAAdvancedFindScope searchScope = [[FRADefaults valueForKey:@"AdvancedFindScope"] integerValue];
+ NSArray *originalDocuments = nil;
+
+ if (searchScope == FRAParentDirectoryScope) {
+ originalDocuments = [NSArray arrayWithArray:[[FRACurrentProject documentsArrayController] arrangedObjects]];
+ }
+
NSString *searchString = [findSearchField stringValue];
NSString *replaceString = [replaceSearchField stringValue];
@@ -335,7 +347,27 @@ - (IBAction)replaceAction:(id)sender
startLocation = NSMaxRange(foundRange);
}
}
- numberOfResults += resultsInThisDocument;
+
+ if (resultsInThisDocument == 0) {
+ // Remove document if no results have been found into it and the document was not loaded before.
+ if ((searchScope == FRAParentDirectoryScope) && (originalDocuments != nil)) {
+ BOOL closing = YES;
+
+ NSEnumerator *originalDocumentsEnumerator = [originalDocuments objectEnumerator];
+ for (id originalDocument in originalDocumentsEnumerator) {
+ if ([[originalDocument valueForKey:@"nameWithPath"] isEqualToString:[document valueForKey:@"nameWithPath"]]) {
+ closing = NO;
+ break;
+ }
+ }
+
+ if (closing)
+ [FRACurrentProject performCloseDocument:document];
+ }
+ }
+ else {
+ numberOfResults += resultsInThisDocument;
+ }
}
if (numberOfResults == 0) {
@@ -619,6 +651,7 @@ -(NSEnumerator *)documentsInFolderEnumerator
[FRAOpenSave shouldOpen:fullyQualifiedName withEncoding:0];
}
else {
+ // no search in subdirectories
[directoryEnumerator skipDescendents];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.