Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions Classes/Controllers/PBRefController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion Classes/PBCommitList.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down