Improve algorithm to find root when using reveal in file browser

The algorithm will avoid changing root when possible. If root has to be changed, we favor the current project folder, if that is not possible, we use the parent for the item being selected, unless the item is in a file package below the project folder, in that case, we use the root of the file package.
This commit is contained in:
Allan Odgaard
2015-08-05 12:29:12 +02:00
parent d550eae4a0
commit 6ffd12e805

View File

@@ -354,26 +354,26 @@ static bool is_binary (std::string const& path)
if(!alreadyVisible)
{
BOOL isChild = NO;
for(NSURL* currentURL = ParentForURL(aURL); currentURL; currentURL = ParentForURL(currentURL))
{
if([currentURL isEqual:_url] || [currentURL isEqual:parentURL])
{
parentURL = currentURL;
isChild = YES;
break;
}
}
BOOL isChild = NO;
for(NSURL* currentURL = ParentForURL(aURL); currentURL && !isChild; currentURL = ParentForURL(currentURL))
if(isChild)
{
if([parentURL isEqual:currentURL])
isChild = YES;
if([currentURL isFileURL] && (path::info([[currentURL path] fileSystemRepresentation]) & path::flag::package))
for(NSURL* currentURL = ParentForURL(aURL); currentURL; currentURL = ParentForURL(currentURL))
{
parentURL = currentURL;
isChild = YES;
break;
if([currentURL isFileURL] && (path::info([[currentURL path] fileSystemRepresentation]) & path::flag::package))
{
parentURL = currentURL;
break;
}
}
}
[self goToURL:isChild ? parentURL : ParentForURL(aURL)];