Skip to content

fix(ui-egui): ink undo starts at the opened page, and can be redone (#155, #156) - #179

Merged
DWAA1660 merged 2 commits into
AlienTechSoftware:mainfrom
DWAA1660:fix/ink-undo-history
Nov 12, 2026
Merged

DWAA1660 merged 2 commits into
AlienTechSoftware:mainfrom
DWAA1660:fix/ink-undo-history

Conversation

@DWAA1660

Copy link
Copy Markdown
Collaborator

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_undo returned true whenever the drawing had strokes. With no recorded change, Pad::undo fell back to Drawing::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. Pad kept undo steps but no redo steps. app.redo only called the page-text history, and can_redo ignored ink, so Ctrl+Y said "Nothing to redo".

Changes:

  • Pad:
    • undo takes back only recorded changes (undo_steps); the fallback is gone. can_undo is !undo_steps.is_empty(). The page's ink as opened is the baseline.
    • New redo_steps: undo pushes the strokes it replaced, and new redo() / 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:
    • undo records what it took back (Undone::Ink, Page or Both) on a small stack. redo pops it and redoes the same target, falling back sensibly if that no longer fits. New ink_redo saves and reports like ink_undo.
    • can_undo / can_redo (Quick Access) and the ribbon's undo/redo flags now include the ink.
    • The record is cleared when another page is opened.

How it was checked

  • New 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.
  • New 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.
  • New UI test 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_again now 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

DWAA1660 and others added 2 commits November 12, 2026 11:35
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>
@DWAA1660

Copy link
Copy Markdown
Collaborator Author

Follow-up commit: the keyboard's Ctrl+Y / Ctrl+Shift+Z still called step_back(false) directly, so a stroke undone with Ctrl+Z could only be redone with the Redo button, not the key the issue reports. Both keys now go through redo(), like the buttons. Extended undo_and_redo_of_ink_follow_what_was_done_this_session to press Ctrl+Z and Ctrl+Y on a real stroke. cargo test -p notecraft-ui-egui passes (304 unit, 202 UI).

@DWAA1660
DWAA1660 merged commit 3077dcf into AlienTechSoftware:main Nov 12, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Undo immediately after reopening a page deletes previously saved ink despite no edits in the new session

1 participant