-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement soft undo/redo #326
Labels
Comments
cmyr
added a commit
to cmyr/xi-editor
that referenced
this issue
Nov 23, 2018
With this patch, we now keep track of selection state as we create and modify undo groups, which lets us restore selections to their state immediately before or after a given edit (edit group) during undo/redo. closes xi-editor#458, closes xi-editor#765 related xi-editor#326, xi-editor#808
cmyr
added a commit
to cmyr/xi-editor
that referenced
this issue
Nov 23, 2018
With this patch, we now keep track of selection state as we create and modify undo groups, which lets us restore selections to their state immediately before or after a given edit (edit group) during undo/redo. I had trouble figuring out exactly what state we wanted to store and how we wanted to represent that. The first version of this just had a single state per undo group; we would always save the last selection state for a given undo group, updating it on movement events. This didn't work. The problem, I think, is that we have different expectations for undo versus redo. As an example, let's say we've just opened a file with the contents, 'hello'. In our view, this looks like, `hello|` where `|` is the cursor. We enter a space and 'world!'; our view looks like `hello world!|`. We use the arrows to select 'world!' (our view looks like `hello [|world!]`) and type 'dear friend'. We now have two undo groups, corresponding to `hello world!` and `hello dear friend`. (We don't include the state of the document when it was opened, which can't be undone.) If we undo, at this stage, we want everything to go back to the state it was in before the last edit; i.e., `hello [|world!]`. If we undo _again_, we should have `hello|`, our starting state. However, what should now happen on _redo_? If we store a single state per edit, we would end up being back at `hello [|world!]`, which I don't think is right; we want `hello world!|`, the state immediately after the 'world!' edit. This means that (at least in some cases) we need to store two separate states; the state to restore on undo (which is the state immediately before the new edit group was crated) and also the state to restore on redo, which is the state immediately after the last edit in the edit group. closes xi-editor#458, closes xi-editor#765 related xi-editor#326, xi-editor#808
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It undoes cursor operations like movement or adding selections.
The text was updated successfully, but these errors were encountered: