Reject saved state with save boundaries outside the commands - #97
Merged
matt-edmondson merged 1 commit intoSep 27, 2026
Merged
Conversation
…tch] IsRestorable checked that save boundaries were non-null but never checked their positions, so a corrupt state with boundaries at -7 or 42 loaded and left phantom save points behind. Require every boundary to sit between -1 and the last command, so RestoreFromState and LoadStateAsync reject the state and keep the live history. Fixes #90 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4m2HJkrsY88XBtTqTKAkE
|
matt-edmondson
deleted the
claude/undoredo-90-validate-boundary-positions
branch
September 27, 2026 00:18
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 #90
What changed
IsRestorable(added in #81) rejected null save boundaries but never checked their positions. A corrupt or hand-edited state with boundaries at-7or42therefore loaded, and the phantom save points ended up inSaveBoundariesand the unsaved-changes logic.It now also requires every boundary to satisfy
-1 <= Position < Commands.Count.RestoreFromStateandLoadStateAsyncreturnfalsefor such a state and leave the live history as it was.Tests
UndoRedoService_RestoreFromStateInvalidBoundaryPosition_ReturnsFalseAndKeepsHistorycovers -7, -2, the command count, and 42.UndoRedoService_LoadStateAsyncInvalidBoundaryPosition_ReturnsFalseAndKeepsHistoryruns the same case through the JSON serializer.UndoRedoService_RestoreFromStateBoundaryAtEdge_Restoreschecks that the valid edges, -1 and the last command, are still accepted.I reverted the one-line fix and the five rejection cases failed. With the fix, the full suite passes (76/76).
Note: the #88 triage proposes the same boundary-range check, so this PR covers that part of #88.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N4m2HJkrsY88XBtTqTKAkE
Generated by Claude Code