Skip to content

fix(html): one undo takes back a whole edit - #904

Open
andiwand wants to merge 1 commit into
mainfrom
fix/undo-whole-edit
Open

andiwand wants to merge 1 commit into
mainfrom
fix/undo-whole-edit

Conversation

@andiwand

Copy link
Copy Markdown
Member

Closes #903.

An edit in the document view's editor can take several steps. Enter inside a run shortens the run, puts its tail beside it and splits the paragraph. undo() and redo() took one step at a time, so one edit needed several undos, and the page showed states between the steps that the reader never made. Decision 6 of docs/design/document-editing.md says that one beforeinput is one undo step.

Each way into the editor, beforeinput, compositionend and format(), now opens a gesture, and every step it performs carries that gesture. undo() and redo() take all steps of the top gesture. The operation log that a save reads does not change.

A first version closed a gesture with a microtask. That merged edits that a script sends one after another in one task, as the browser checks and a host can do, so the gesture now opens explicitly at each way in.

test/browser/text/tests.html expected the extra steps after a split. It now expects one step, and two new checks pin that redo replays the split whole and that two edits stay two steps. Run by hand in Chrome: 174 checks, 0 failed. Changelog entry added.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LosSkagYUDarkPra2pGTnP

An edit can take several steps: Enter inside a run shortens the run, puts its
tail beside it and splits the paragraph. `undo()` and `redo()` took one step at
a time, so one edit needed several undos, and the page showed states between
the steps that the reader never made. Decision 6 of
`docs/design/document-editing.md` says that one `beforeinput` is one undo step.

Each way into the editor, `beforeinput`, `compositionend` and `format()`, now
opens a gesture, and every step it performs carries that gesture. `undo()` and
`redo()` take all steps of the top gesture. The operation log does not change.

The browser checks expected the extra steps after a split. They now expect one
step, and two new checks pin that redo replays the split whole and that two
edits stay two steps. 174 checks, 0 failed.

Closes #903.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LosSkagYUDarkPra2pGTnP
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.

Document editor: one undo takes back only part of an edit

1 participant