Repository navigation
fix: collapse the empty text layer discard instead of undoing blindly - #46
Merged
IAmJSD merged 1 commit intoAug 27, 2026
Merged
Conversation
This was referenced Aug 26, 2026
ProdigyRahul
marked this pull request as ready for review
August 26, 2026 12:25
Contributor
Author
Member
|
I've seen. Whilst I do appreciate your PRs, they take time to review. |
IAmJSD
approved these changes
Aug 27, 2026
IAmJSD
left a comment
Member
There was a problem hiding this comment.
Reviewed by Claude (Fable 5) on Astrid's behalf. Confirmed the old path double-undid arbitrary edits and misused pop_redo (pushing unwound entries back without re-applying), and that the new name-guarded pair-drop is conservative — an interleaved edit leaves both entries honestly in history. Both regression tests fail on main. One future-proofing note, non-blocking: drop_cancelling_pair matches by display name; matching on the insert op's LayerId would make it robust if another code path ever commits an edit named "New Text Layer". Merging.
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 #45
add
History::drop_cancelling_pair, which removes the newest two undo entries only when they are exactly the pair named, and use it to collapse the insert and its removal. nothing is dropped unless both are still on top, so an edit committed in between is never touched.the old code could not be right either way:
undo()unwinds whatever is on top rather than this layer's own insert, andpop_redo()is the redo primitive, so it pushed the junk back onto the undo stack instead of discarding it.the regression test commits a real edit while the empty session is open, which is the case that actually loses data. it fails on main with
the edit made during the session must survive: ["bg", "Text"]— the user's layer gone, the empty text layer still there.578 tests pass, clippy and fmt clean.
before
the levels layer made during the empty session is gone; the empty text layer stayed.
after
the levels layer survives; the empty text layer is discarded.