From 8ecf92e893d08031882b72009425d49941c8cdd9 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Fri, 14 Mar 2014 22:44:22 +0700 Subject: [PATCH] Disambiguate display names for SCM data source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For example if multiple files with same base name are modified or untracked, then previously it wasn’t possible to tell them apart (other than using the tool tip which show full path). --- .../OakFileBrowser/src/io/FSSCMDataSource.mm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Frameworks/OakFileBrowser/src/io/FSSCMDataSource.mm b/Frameworks/OakFileBrowser/src/io/FSSCMDataSource.mm index ddc94fdf..a6b656a3 100644 --- a/Frameworks/OakFileBrowser/src/io/FSSCMDataSource.mm +++ b/Frameworks/OakFileBrowser/src/io/FSSCMDataSource.mm @@ -22,14 +22,18 @@ static NSURL* URLAppend (NSURL* base, NSString* relativePath) static NSArray* convert (std::vector const& paths, std::string const& wcPath, NSUInteger options, bool hideSCMBadge = false) { + auto parents = path::disambiguate(paths); + auto parent = parents.begin(); + NSMutableArray* res = [NSMutableArray array]; for(auto const& path : paths) { - FSItem* item = [FSItem itemWithURL:[NSURL fileURLWithPath:[NSString stringWithCxxString:path]]]; - item.target = [NSURL fileURLWithPath:[NSString stringWithCxxString:path]]; - item.labelIndex = path::label_index(path); - item.toolTip = [NSString stringWithCxxString:path::relative_to(path, wcPath)]; - item.leaf = YES; + FSItem* item = [FSItem itemWithURL:[NSURL fileURLWithPath:[NSString stringWithCxxString:path]]]; + item.displayName = [NSString stringWithCxxString:path::display_name(path, *parent++)]; + item.target = [NSURL fileURLWithPath:[NSString stringWithCxxString:path]]; + item.labelIndex = path::label_index(path); + item.toolTip = [NSString stringWithCxxString:path::relative_to(path, wcPath)]; + item.leaf = YES; if(hideSCMBadge) item.icon.scmStatus = scm::status::none;