Same undo history: 100 characters, or 5 million?
transcript
Same document. Same undo history. One design keeps 100 characters. The other keeps over 5 million.
Way one: save a copy of the whole document before each edit. Undo restores the copy. Simple. It can't get an inverse wrong. Way two: record each edit, and how to reverse it. Keep only what changed.
The demo: 50,000 characters, 200 one-letter edits, the last 100 kept. Commands hold 100 characters. You can barely see the bar. Snapshots hold 5,014,950. About 50,000 times more.
But here's the catch. Every command needs an exact inverse. And a delete is the subtle one.
An insert needs its position and its text. Undo deletes it. A delete must carry the text it removed. Once it's gone, nothing else remembers it. Not even the document.
Snapshots still have a job: small state, autosave, rare checkpoints. For keystroke undo on real documents? Commands win by orders of magnitude. Store the change, not the document.
Full breakdown in the lecture.