Disambiguate display names for SCM data source

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).
This commit is contained in:
Allan Odgaard
2014-03-14 22:44:22 +07:00
parent 7131e82102
commit 8ecf92e893

View File

@@ -22,14 +22,18 @@ static NSURL* URLAppend (NSURL* base, NSString* relativePath)
static NSArray* convert (std::vector<std::string> 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;