From 391fc474f3e2d1845ff4275f0a7e6d94dc378eed Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 21 Jan 2022 15:00:27 -0800 Subject: [PATCH] Drag and Drop: Made DND undo possibly less janky --- Playlist/DNDArrayController.m | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Playlist/DNDArrayController.m b/Playlist/DNDArrayController.m index 50875e6cb..4dd6646cf 100755 --- a/Playlist/DNDArrayController.m +++ b/Playlist/DNDArrayController.m @@ -121,20 +121,19 @@ NSString *iTunesDropType = @"com.apple.tv.metadata"; - (void)moveObjectsFromIndex:(NSUInteger)fromIndex toArrangedObjectIndexes:(NSIndexSet *)indexSet { - NSArray *objects = [self arrangedObjects]; + NSArray *objects = [[self arrangedObjects] subarrayWithRange:NSMakeRange(fromIndex, [indexSet count])]; NSUInteger index = [indexSet firstIndex]; NSUInteger itemIndex = 0; id object; - NSArray *itemsSet = [objects objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(fromIndex, [indexSet count])]]; - - for (NSUInteger i = 0; i < [itemsSet count]; i++) { - [self removeObjectAtArrangedObjectIndex:fromIndex]; + fromIndex += [objects count]; + for (NSUInteger i = 0; i < [objects count]; i++) { + [self removeObjectAtArrangedObjectIndex:--fromIndex]; } while (NSNotFound != index) { - object = itemsSet[itemIndex++]; + object = objects[itemIndex++]; [self insertObject:object atArrangedObjectIndex:index];