Repository navigation
Roll back an undo or redo whose NavigationChanged handler throws [patch] - #112
Open
matt-edmondson wants to merge 2 commits into
Open
matt-edmondson wants to merge 2 commits into
matt-edmondson wants to merge 2 commits into
Conversation
RestoreState swapped in the restored items and index, then raised NavigationChanged. When a handler threw, SimpleUndoRedoProvider put the action back as though it had never run, but the stack had already moved, so the stack and its history disagreed: after a failed undo the page was undone while Redo stayed disabled and the next undo did nothing visible. RestoreState now puts the stack back to its state before the restore when a handler throws, then rethrows, which keeps the provider's assumption that an action that throws changed nothing. Fixes #75 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5pmswBjLMVcM1HgMb
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5pmswBjLMVcM1HgMb
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #75
What was wrong
Navigation<T>.RestoreStateswapped in the restored items and index first, and raisedNavigationChangedafter. When a handler threw,SimpleUndoRedoProviderput the action back as though it had never run, but the stack had already moved. After a failed undo the page was undone,CanRedowas false, and the next undo appeared to do nothing. A failed redo had the same problem in reverse.Change
RestoreStatekeeps the items and index from before the restore. If a handler throws, it puts the stack back to that state under the lock and rethrows. This keeps the provider's documented assumption that an action that throws changed nothing. The method's remarks now say so.Tests
Undo_WhenAHandlerThrows_LeavesTheStackAndTheHistoryInAgreement: after the throw the stack is stillA,B,CatCwith 3 undo entries and nothing to redo, and the next undo goes toB.Redo_WhenAHandlerThrows_LeavesTheStackAndTheHistoryInAgreementis the mirror case for redo.Both fail on
main(the stack is already undone or redone) and pass with the fix. Full suite: 67 tests, 65 passed, 2 skipped (the unreadable-file tests are inconclusive when run as root).The branch has a second commit that reverts a
.gitignorechange the local build made. The net diff touches only the two files above.Generated by Claude Code