Repository navigation
fix(ui-egui): ink undo starts at the opened page, and can be redone (#155, #156) - #179
Merged
Merged
Conversation
Undo on a page just opened, with nothing done, took away a stroke that had been saved with the page: with no change to go back to, the pad fell back to popping the drawing's last stroke (AlienTechSoftware#156). And a stroke taken back could never be put back: the pad kept no redo steps, and Redo only knew the page's text history (AlienTechSoftware#155). The pad now takes back only changes made since the page was opened, and keeps what it took back for redo until a new change starts another branch. The window remembers whether each Undo went to the ink, the page or both, and Redo goes back the same way; the Undo and Redo buttons count the ink too. Fixes AlienTechSoftware#155 Fixes AlienTechSoftware#156 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The keyboard's Ctrl+Y and Ctrl+Shift+Z still called the page history's step directly, so a stroke taken back with Ctrl+Z could only be put back with the Redo button. They now go through the same redo as the button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Follow-up commit: the keyboard's Ctrl+Y / Ctrl+Shift+Z still called |
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.
What and why
Fixes #156 and #155. Both live in the ink's undo history (
inkpad::Pad) and the window's Undo/Redo routing (app.rs). They change the same functions, so they're one PR.#156: Undo after reopening deleted saved ink.
Pad::can_undoreturned true whenever the drawing had strokes. With no recorded change,Pad::undofell back toDrawing::undo(), which popped a stroke loaded from disk. Opening a page and pressing Undo, with no edits, deleted durable ink.#155: an undone stroke couldn't be redone.
Padkept undo steps but no redo steps.app.redoonly called the page-text history, andcan_redoignored ink, so Ctrl+Y said "Nothing to redo".Changes:
Pad:undotakes back only recorded changes (undo_steps); the fallback is gone.can_undois!undo_steps.is_empty(). The page's ink as opened is the baseline.redo_steps:undopushes the strokes it replaced, and newredo()/can_redo()put them back (as an undoable step again).settle()clears the redo stack when a new change is recorded, so a new stroke starts a new branch.app.rs:undorecords what it took back (Undone::Ink,PageorBoth) on a small stack.redopops it and redoes the same target, falling back sensibly if that no longer fits. Newink_redosaves and reports likeink_undo.can_undo/can_redo(Quick Access) and the ribbon's undo/redo flags now include the ink.How it was checked
inkpad::tests::undo_after_opening_a_page_leaves_its_ink_alone([BUG] Undo immediately after reopening a page deletes previously saved ink despite no edits in the new session #156): a reopened pad can't undo and keeps its saved stroke, and a stroke drawn after opening can be undone back to exactly the opened state.inkpad::tests::redo_puts_back_what_undo_took([BUG] Undoing an ink stroke cannot be redone; Ctrl+Y reports Nothing to redo #155): undo twice, redo twice in order, undo after redo, and a new stroke clears redo.undo_and_redo_of_ink_follow_what_was_done_this_session. It draws a real stroke with the pen, then Undo → 0 strokes, Redo → 1 stroke. After going to another page and back, Undo leaves the saved stroke.rubbing_a_page_clean_takes_the_file_away_againnow adds its stroke the way the pen does, as a recorded change, since a stroke pushed straight into the drawing is no longer undoable.cargo test -p notecraft-ui-egui: all pass (304 unit, 202 UI)cargo fmt --all -- --check,cargo clippy -p notecraft-ui-egui --all-targets -- -D warnings: clean🤖 Generated with Claude Code