Merge pull request #3333 from enquora/integration-test-document-based-app

Undo functionality: verify behaviour, fix accidentally disclosed edge…
This commit is contained in:
David Richardson authored and GitHub committed 2026-10-23 15:56:19 -06:00
commit 263f7a4038
3 files changed
+26 -3

No files matched your search

+4
View File
@@ -347,8 +347,12 @@ if (_currentGroup == nil)
*/
- (void)undo
{
// Closing the grouping here also cancels the run loop's scheduled close of the event grouping.
if ([self groupingLevel] === 1)
{
[self endUndoGrouping];
[self _unregisterWithRunLoop];
}
[self undoNestedGroup];
}
+21 -1
View File
@@ -57,6 +57,26 @@
[[CPNotificationCenter defaultCenter] removeObserver:self];
}
- (void)testUndoInSameRunLoopCycleAsChange
{
[self doIt];
// The change opened an event grouping that the run loop is scheduled to close. Undo closes it first.
[undoManager undo];
[self assertFalse:itIsDone message:@"undo should revert the change"];
// The scheduled close must not run against the grouping that undo already closed.
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
[self assert:0 equals:[undoManager groupingLevel]];
[self assertTrue:[undoManager canRedo] message:@"the undone change should be available to redo"];
[undoManager redo];
[self assertTrue:itIsDone message:@"redo should reapply the change"];
}
- (void)receiveNotification:(CPNotification)aNotification
{
[receivedNotifications addObject:aNotification];
@@ -74,7 +94,7 @@
- (void)undoIt
{
[undoManager registerUndoWithTarget:self
selector:@selector(doit)
selector:@selector(doIt)
object:nil];
itIsDone = NO;
+1 -2
View File
@@ -25,7 +25,6 @@ TextEditor is a document-based test application and a tutorial. When the app use
### Undo and redo
- **Redo is unreliable or does not work.** Not yet investigated.
- **Undo stays enabled when `allowsUndo` is `NO`.** `-[CPTextView undo:]` then does nothing (`CPTextView.j:679`). The text view must disable the menu item in that case.
### Clipboard
@@ -66,7 +65,7 @@ TextEditor is a document-based test application and a tutorial. When the app use
- One window for each document, each loaded from its own cib.
- Insert Lorem Ipsum through the responder chain.
- Undo over several levels, separate for each document.
- Undo and redo over several levels, separate for each document.
- Text colour through `CPColorPanel`.
- Paragraph indents through the ruler markers.
- The "save changes" alert when a document closes.