cursorless
cursorless copied to clipboard
Phrase-level undo command
The problem
As we become more adventurous with long command phrases, it becomes more painful to undo a command phrase that has gone wrong. We'd like to be able to undo everything done by a single phrase, even if it corresponds to many edits, potentially across multiple editors
The solution
We should probably implement this one as a separate extension. Seems more generic than just for cursorless
M1: The basics
- [ ] Take snapshot of document upon opening it, and after any change in an open editor
- [ ] Any time talon sends pre-phrase signal, set a flag, and then any time a document changes mark the previous version so that we can snap back to it
- [ ] When user issues a "phrase-level undo", extension will repeatedly issue undo commands in each editor that has had a change until its contents match snapshot. Need some mechanism to keep this from getting out of hand if something is amiss and for whatever reason the document never matches the snapshot
- [ ] Keep a sequence of these "phrase-level actions" so can undo multiple in a row
M2: Other types of actions
- [ ] Keep track of editor selections and undo those
- [ ] Keep track of editor visible ranges and undo scroll
- [ ] Allow extensions to register reverse actions. That way can undo other side effects, make it easier to handle scroll, and not add spam to cursorless selection history tracking
M3 Unopened documents
Handle changes to documents that are not open in an editor
- [ ] Extensions can signal that they are about to change a document that is not open
- [ ] Any time a document changes that is not open, if it has been signalled by an extension, we handle it like an open editor, except that we can't use undo action; we have to just restore the snapshot
- [ ] If a document changes that is not open and hasn't been signalled by an extension, we refuse to handle it as an undo because it could be a git command or something and we don't want to mess something up. Or I guess we could warn
M4 Undo tree
- [ ] Add an undo tree so that if user issues an undo, then does something, that creates a branch. Can steal a display from a git log plugin or something