Skip to content

fix(ui-egui): typing after an undo starts a new history step (#160) - #183

Merged
DWAA1660 merged 1 commit into
AlienTechSoftware:mainfrom
DWAA1660:fix/history-branch-boundary
Nov 12, 2026
Merged

DWAA1660 merged 1 commit into
AlienTechSoftware:mainfrom
DWAA1660:fix/history-branch-boundary

Conversation

@DWAA1660

Copy link
Copy Markdown
Collaborator

What and why

Fixes #160. history::History::record truncated the redo steps and then called folds_into_last. That merges typing into the current step when it's the same Kind::Typing(block) within the 700 ms pause. Straight after an Undo, the current step is the state Undo had just restored. Typing then overwrote it in place, and the next Undo skipped past it. In the issue's sequence, typing abc, an edit, Undo, then X within the window, the final Undo returned "" instead of "abc".

record now notes whether there were redo steps (at + 1 < steps.len()) before truncating them. If there were, the user branched from an Undo and the new step never folds. It becomes a step of its own after the restored state. Contiguous typing with no Undo in between still coalesces as before.

How it was checked

  • New history::tests::typing_after_an_undo_is_a_step_of_its_own:
    • the issue's sequence: after the new X, Undo returns abc, then "". Redo walks forward through abc → abcX on the new branch and stops.
    • a control: three keystrokes of ordinary typing are still a single step
    • Fails without the fix ("" instead of abc), and passes with it
  • Existing history tests unchanged and passing
  • cargo test -p notecraft-ui-egui: all pass (303 unit, 202 UI)
  • cargo fmt --all -- --check, cargo clippy -p notecraft-ui-egui --all-targets -- -D warnings: clean

🤖 Generated with Claude Code

`History::record` dropped the redo steps and then let new typing fold
into the step it was on. After an Undo, that is the state Undo had just
restored: typing in the same block within the pause replaced it, so the
next Undo went past it and the restored state was lost (AlienTechSoftware#160).

A step recorded while there were redo steps now always starts a new
step. Ordinary runs of typing still fold into one.

Fixes AlienTechSoftware#160

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DWAA1660
DWAA1660 merged commit 2fa5e54 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] Typing coalescing crosses an Undo branch and destroys the restored state's undo boundary

1 participant