From c21387adfb44997c48f27edf1491ba9f6fec5e75 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Tue, 30 Oct 2018 18:52:30 +0700 Subject: [PATCH] =?UTF-8?q?Selecting=20file=20outside=20project=20(?= =?UTF-8?q?=E2=8C=83=E2=8C=98R)=20would=20fail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/FileBrowserViewController.mm | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Frameworks/FileBrowser/src/FileBrowserViewController.mm b/Frameworks/FileBrowser/src/FileBrowserViewController.mm index bd7d789a..4943010e 100644 --- a/Frameworks/FileBrowser/src/FileBrowserViewController.mm +++ b/Frameworks/FileBrowser/src/FileBrowserViewController.mm @@ -992,13 +992,26 @@ static bool is_binary (std::string const& path) NSMutableSet* expandURLs = [self.fileBrowserView.expandedURLs mutableCopy]; NSURL* childURL = url; - while([childURL getResourceValue:&childURL forKey:NSURLParentDirectoryURLKey error:nil] && ![childURL isEqual:parentURL]) + while(true) { + NSNumber* flag; + if([childURL getResourceValue:&flag forKey:NSURLIsVolumeKey error:nil] && [flag boolValue]) + break; + + NSURL* potentialParentURL; + if(![childURL getResourceValue:&potentialParentURL forKey:NSURLParentDirectoryURLKey error:nil] || [childURL isEqual:potentialParentURL]) + break; + + childURL = potentialParentURL; if([childURL isEqual:currentParent]) { parentURL = currentParent; break; } + + if([childURL isEqual:parentURL]) + break; + [expandURLs addObject:childURL]; } @@ -1007,6 +1020,11 @@ static bool is_binary (std::string const& path) [self goToURL:parentURL]; [self.fileBrowserView expandURLs:expandURLs.allObjects selectURLs:@[ url ]]; } + else + { + [self goToURL:url.URLByDeletingLastPathComponent]; + [self.fileBrowserView expandURLs:nil selectURLs:@[ url ]]; + } } - (void)reload:(id)sender