diff --git a/Classes/Controllers/PBRefController.m b/Classes/Controllers/PBRefController.m index ec27403a4..7836bf69a 100644 --- a/Classes/Controllers/PBRefController.m +++ b/Classes/Controllers/PBRefController.m @@ -339,29 +339,40 @@ - (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexe NSPoint location = [(PBCommitList *)tv mouseDownPoint]; int row = [tv rowAtPoint:location]; int column = [tv columnAtPoint:location]; - int subjectColumn = [tv columnWithIdentifier:@"SubjectColumn"]; - if (column != subjectColumn) - return NO; PBGitRevisionCell *cell = (PBGitRevisionCell *)[tv preparedCellAtColumn:column row:row]; - NSRect cellFrame = [tv frameOfCellAtColumn:column row:row]; - - int index = [cell indexAtX:(location.x - cellFrame.origin.x)]; - - if (index == -1) - return NO; - - PBGitRef *ref = [[[cell objectValue] refs] objectAtIndex:index]; - if ([ref isTag] || [ref isRemoteBranch]) - return NO; + PBGitCommit *commit = [[commitController arrangedObjects] objectAtIndex:row]; - if ([[[historyController.repository headRef] ref] isEqualToRef:ref]) - return NO; - - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:row], [NSNumber numberWithInt:index], NULL]]; - [pboard declareTypes:[NSArray arrayWithObject:@"PBGitRef"] owner:self]; - [pboard setData:data forType:@"PBGitRef"]; + int index = -1; + if ([cell respondsToSelector:@selector(indexAtX:)]) { + NSRect cellFrame = [tv frameOfCellAtColumn:column row:row]; + index = [cell indexAtX:(location.x - cellFrame.origin.x)]; + } + if (index != -1) { + PBGitRef *ref = [[commit refs] objectAtIndex:index]; + if ([ref isTag] || [ref isRemoteBranch]) + return NO; + + if ([[[historyController.repository headRef] ref] isEqualToRef:ref]) + return NO; + + NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:row], [NSNumber numberWithInt:index], NULL]]; + [pboard declareTypes:[NSArray arrayWithObject:@"PBGitRef"] owner:self]; + [pboard setData:data forType:@"PBGitRef"]; + } else { + [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self]; + + NSString *info = nil; + if (column == [tv columnWithIdentifier:@"ShortSHAColumn"]) { + info = [commit shortName]; + } else { + info = [NSString stringWithFormat:@"%@ (%@)", [[commit realSha] substringToIndex:10], [commit subject]]; + } + + [pboard setString:info forType:NSStringPboardType]; + } + return YES; } diff --git a/Classes/PBCommitList.m b/Classes/PBCommitList.m index 8892e131f..ad7c6d388 100644 --- a/Classes/PBCommitList.m +++ b/Classes/PBCommitList.m @@ -106,7 +106,12 @@ - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows PBGitRevisionCell *cell = (PBGitRevisionCell *)[self preparedCellAtColumn:column row:row]; NSRect cellFrame = [self frameOfCellAtColumn:column row:row]; - int index = [cell indexAtX:(location.x - cellFrame.origin.x)]; + int index = -1; + + if ([cell respondsToSelector:@selector(indexAtX:)]) { + index = [cell indexAtX:(location.x - cellFrame.origin.x)]; + } + if (index == -1) return [super dragImageForRowsWithIndexes:dragRows tableColumns:tableColumns event:dragEvent offset:dragImageOffset];