Drag and Drop: Made DND undo possibly less janky

CQTexperiment
Christopher Snowhill 2022-01-21 15:00:27 -08:00
parent 297b7b2909
commit 391fc474f3
1 changed files with 5 additions and 6 deletions

View File

@ -121,20 +121,19 @@ NSString *iTunesDropType = @"com.apple.tv.metadata";
- (void)moveObjectsFromIndex:(NSUInteger)fromIndex - (void)moveObjectsFromIndex:(NSUInteger)fromIndex
toArrangedObjectIndexes:(NSIndexSet *)indexSet { toArrangedObjectIndexes:(NSIndexSet *)indexSet {
NSArray *objects = [self arrangedObjects]; NSArray *objects = [[self arrangedObjects] subarrayWithRange:NSMakeRange(fromIndex, [indexSet count])];
NSUInteger index = [indexSet firstIndex]; NSUInteger index = [indexSet firstIndex];
NSUInteger itemIndex = 0; NSUInteger itemIndex = 0;
id object; id object;
NSArray *itemsSet = [objects objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(fromIndex, [indexSet count])]]; fromIndex += [objects count];
for (NSUInteger i = 0; i < [objects count]; i++) {
for (NSUInteger i = 0; i < [itemsSet count]; i++) { [self removeObjectAtArrangedObjectIndex:--fromIndex];
[self removeObjectAtArrangedObjectIndex:fromIndex];
} }
while (NSNotFound != index) { while (NSNotFound != index) {
object = itemsSet[itemIndex++]; object = objects[itemIndex++];
[self insertObject:object atArrangedObjectIndex:index]; [self insertObject:object atArrangedObjectIndex:index];