diff --git a/AppKit/Cib/CPCib.j b/AppKit/Cib/CPCib.j index 7277e8bca..c9c9a3da0 100644 --- a/AppKit/Cib/CPCib.j +++ b/AppKit/Cib/CPCib.j @@ -162,7 +162,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey"; - (BOOL)instantiateCibWithOwner:(id)anOwner topLevelObjects:(CPArray)topLevelObjects { - return [self instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObjectsAndKeys:anOwner, CPCibOwner, topLevelObjects, CPCibTopLevelObjects]]; + return [self instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObjects:[anOwner, topLevelObjects] forKeys:[CPCibOwner, CPCibTopLevelObjects]]]; } @end diff --git a/Foundation/CPUndoManager.j b/Foundation/CPUndoManager.j index 16a70cd37..42c24163b 100644 --- a/Foundation/CPUndoManager.j +++ b/Foundation/CPUndoManager.j @@ -35,6 +35,7 @@ var CPUndoManagerNormal = 0, CPUndoManagerCheckpointNotification = @"CPUndoManagerCheckpointNotification"; CPUndoManagerDidOpenUndoGroupNotification = @"CPUndoManagerDidOpenUndoGroupNotification"; +CPUndoManagerDidCloseUndoGroupNotification = @"CPUndoManagerDidCloseUndoGroupNotification"; CPUndoManagerDidRedoChangeNotification = @"CPUndoManagerDidRedoChangeNotification"; CPUndoManagerDidUndoChangeNotification = @"CPUndoManagerDidUndoChangeNotification"; CPUndoManagerWillCloseUndoGroupNotification = @"CPUndoManagerWillCloseUndoGroupNotification"; @@ -490,6 +491,10 @@ if (_currentGroup == nil) if (_levelsOfUndo > 0 && stack.length > _levelsOfUndo) stack.splice(0, 1); + + [defaultCenter + postNotificationName:CPUndoManagerDidCloseUndoGroupNotification + object:self]; } // Nested Undo Grouping diff --git a/Tests/Foundation/CPIndexSetTest.j b/Tests/Foundation/CPIndexSetTest.j index 8641ae5c7..fefbd220d 100644 --- a/Tests/Foundation/CPIndexSetTest.j +++ b/Tests/Foundation/CPIndexSetTest.j @@ -288,6 +288,9 @@ function descriptionWithoutEntity(aString) { [self assert:[_set lastIndex] equals:19]; [self assert:[[CPIndexSet indexSet] lastIndex] equals:CPNotFound]; + + var singleIndexSet = [CPIndexSet indexSetWithIndex:3]; + [self assert:3 equals:[singleIndexSet lastIndex]]; } /* - (void)testAddSpeed diff --git a/Tests/Foundation/CPUndoManagerTest.j b/Tests/Foundation/CPUndoManagerTest.j index 857794eba..67ef6308c 100644 --- a/Tests/Foundation/CPUndoManagerTest.j +++ b/Tests/Foundation/CPUndoManagerTest.j @@ -3,12 +3,16 @@ @implementation CPUndoManagerTest : OJTestCase { - CPUndoManager undoManager; + CPArray receivedNotifications; + CPUndoManager undoManager; + BOOL itIsDone; } - (void)setUp { undoManager = [[CPUndoManager alloc] init]; + itIsDone = NO; + receivedNotifications = [CPMutableArray array]; } - (void)testUndoMenuTitleForUndoActionName @@ -35,4 +39,46 @@ [self assert:[undoManager redoMenuTitleForUndoActionName:"STRING"] equals:@"Redo STRING"]; } +- (void)testNotifications +{ + + [[CPNotificationCenter defaultCenter] addObserver:self + selector:@selector(receiveNotification:) + name:CPUndoManagerDidCloseUndoGroupNotification + object:undoManager]; + + [self doIt]; + + // The default run loop undo grouping won't be closed until the next run loop cycle. + [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; + + CPLog.error("receivedNotifications: %@", receivedNotifications); + [self assert:CPUndoManagerDidCloseUndoGroupNotification equals:[receivedNotifications[0] name]]; + + [[CPNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)receiveNotification:(CPNotification)aNotification +{ + [receivedNotifications addObject:aNotification]; +} + +- (void)doIt +{ + [undoManager registerUndoWithTarget:self + selector:@selector(undoIt) + object:nil]; + + itIsDone = YES; +} + +- (void)undoIt +{ + [undoManager registerUndoWithTarget:self + selector:@selector(doit) + object:nil]; + + itIsDone = NO; +} + @end