Repository navigation
refactor(core): undo and redo take the editors' own answer, with no body special case - #6
Merged
Conversation
…ody special case leaf's `can_undo` now mirrors twig's stacks exactly and `Doc::undo` / `Doc::redo` return whether they moved, so a body entry is only pressed when leaf has a step to take. `DocumentSession::undo` and `redo` read the verbs' `bool` instead of snapshotting both change counters around the call, and drop the "walk on when the body did not move" arm: a pressed step that does not move is a refusal in either editor, and keeps its entry. Closes leaf's task can-undo-counts-edits-not-steps (its provui half). Behavioural-change: a body undo or redo that leaf refuses after reporting a step to take (twig failing) now stops the walk and leaves its journal entry in place, where it used to drop the entry and go on to the next one.
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 changed
DocumentSession::undoandredo(crates/provui-core/src/session.rs) now use theboolthatleaf_core::Doc::undo/redoandflower_core::Model::undo/redoreturn. They used to snapshot both change counters around the call and compare them. Thenothing_happenedhelper is gone, and with it the body-only "walk on when the body did not move" arm. A step that is pressed and does not move now stops the walk in either editor, and its journal entry stays where it was. The metadata side already worked this way.Exhaustion skipping stays as it was. Body entries left over after a coalesced run are passed over before they are pressed, because leaf's
can_undois exact.Two smaller changes in the same file: a leftover debug
eprintln!is removed froma_coalesced_run_of_typing_does_not_cost_a_keypress_per_character, andcounters()is folded intomark_seen, its only remaining caller.Why
This is provui's half of leaf's task
can-undo-counts-edits-not-steps. Its done-when says provui'sDocumentSessioncan drop the "walk on when the body did not move" special case. That case existed because leaf'scan_undocounted edits rather than twig's steps. leaf has fixed that, and provui's lock (leaf712f12e) already includes the fix.Behavioural change: if leaf refuses a body undo or redo after reporting a step to take (twig failing), the walk now stops and keeps its entry. Before, it dropped the entry and carried on to older entries, so a metadata edit could be undone in answer to a body step that failed.
Task
This closes the remaining half of leaf
docs/tasks/can-undo-counts-edits-not-steps.md. The task file lives in leaf, so it cannot be closed on this branch. It should be moved toclosed/in leaf once this PR is merged.Verification
ship cipassed locally: fmt, clippy-D warnings, tests, docs, package isolation and MSRV.undo_says_whether_it_moved_and_can_undo_ends_with_the_body. Five characters are typed, then undone until the body stops moving. Eachundo()'s answer must match whether the body's revision moved, and at the endcan_undo()must be false and redo must work.maintoo. The arm removed here was unreachable with an exactcan_undo, so no test can fail before the change. The existing undo tests in core and the TUI also pass unchanged.