-
Notifications
You must be signed in to change notification settings - Fork 152
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
More intelligent undo system #502
Comments
I think option three is reasonable @disordinary. But if you investigate and realize otherwise I would welcome some insight. Five is fairly arbitrary, and it should also be configurable via |
Option 3 also seems reasonable to me. I don't think this would cause any issues. Moving the codebase in the direction of having a better understanding of what logical changes are being made is a goal, in order to simplify a more-intelligent undo like you're proposing here, and to better facilitate concurrent editing. |
Yes that makes sense, it's obviously a huge job though. It's probably best to sort out the undo in the near term and then look at a bigger re-engineering exercise later on. Out of curiosity, do bustle or any other users of mobiledoc have any issues with the undo system? Because it could just be that I am undo happy but to me it's quite a big impediment. Anyway, I'll start digging around in the codebase over the next couple of days and start working on it, no doubt I will have some questions which I'll ask in gitter. Can you think of any scenarios in addition to the 7 above that will have an affect on the undo flow? |
Refs bustle#502 Basically there are three types of UNDO events, content insert, content delete, and everything else. content insert and content delete events group together overwriting the last element in the undo queue unless another event occurs which breaks it or a timeout occurs. So, if I write text then as long as I don't delete text or insert an atom or card, and as long as the timeout doesn't occur, those events are grouped and undo in one go. A timeout is reset whenever the `run` method is called on the editor, so it doesn't occur on the first occurence of an event in a run but rather the last.
Refs bustle#502 Basically there are three types of UNDO events, content insert, content delete, and everything else. content insert and content delete events group together overwriting the last element in the undo queue unless another event occurs which breaks it or a timeout occurs. So, if I write text then as long as I don't delete text or insert an atom or card, and as long as the timeout doesn't occur, those events are grouped and undo in one go. A timeout is reset whenever the `run` method is called on the editor, so it doesn't occur on the first occurence of an event in a run but rather the last.
Refs bustle#502 Basically there are three types of UNDO events, content insert, content delete, and everything else. content insert and content delete events group together overwriting the last element in the undo queue unless another event occurs which breaks it or a timeout occurs. So, if I write text then as long as I don't delete text or insert an atom or card, and as long as the timeout doesn't occur, those events are grouped and undo in one go. A timeout is reset whenever the `run` method is called on the editor, so it doesn't occur on the first occurence of an event in a run but rather the last.
Refs bustle#502 Basically there are three types of UNDO events, content insert, content delete, and everything else. content insert and content delete events group together overwriting the last element in the undo queue unless another event occurs which breaks it or a timeout occurs. So, if I write text then as long as I don't delete text or insert an atom or card, and as long as the timeout doesn't occur, those events are grouped and undo in one go. A timeout is reset whenever the `run` method is called on the editor, so it doesn't occur on the first occurence of an event in a run but rather the last.
Refs bustle#502 Basically there are three types of UNDO events, content insert, content delete, and everything else. content insert and content delete events group together overwriting the last element in the undo queue unless another event occurs which breaks it or a timeout occurs. So, if I write text then as long as I don't delete text or insert an atom or card, and as long as the timeout doesn't occur, those events are grouped and undo in one go. A timeout is reset whenever the `run` method is called on the editor, so it doesn't occur on the first occurence of an event in a run but rather the last.
Refs bustle#502 Basically there are three types of UNDO events, content insert, content delete, and everything else. content insert and content delete events group together overwriting the last element in the undo queue unless another event occurs which breaks it or a timeout occurs. So, if I write text then as long as I don't delete text or insert an atom or card, and as long as the timeout doesn't occur, those events are grouped and undo in one go. A timeout is reset whenever the `run` method is called on the editor, so it doesn't occur on the first occurence of an event in a run but rather the last.
Refs bustle#502 Basically there are three types of UNDO events, content insert, content delete, and everything else. content insert and content delete events group together overwriting the last element in the undo queue unless another event occurs which breaks it or a timeout occurs. So, if I write text then as long as I don't delete text or insert an atom or card, and as long as the timeout doesn't occur, those events are grouped and undo in one go. A timeout is reset whenever the `run` method is called on the editor, so it doesn't occur on the first occurence of an event in a run but rather the last.
We created three types of events can be stored in the edit history. Markup insertions, deletions, and all other actions. When a markup insertion or deletions happens within Xms of a previous edit of the same type, those edits may be "grouped" for undo/redo. Practically, it means the pending snapshot on history is stomped with the more recent snapshot.
Closing as PR now merged. |
We created three types of events can be stored in the edit history. Markup insertions, deletions, and all other actions. When a markup insertion or deletions happens within Xms of a previous edit of the same type, those edits may be "grouped" for undo/redo. Practically, it means the pending snapshot on history is stomped with the more recent snapshot.
Currently every change in the post is placed on the undo stack, because of memory restrictions that stack is restricted to five. This means that a user can only undo the last five characters typed.
Usually multiple events of the same type group together as one object on the undo stack.
Events which effect undo and redo can broadly be grouped into the following (and there are likely more):
Transitioning from one event type to another creates a single element on the undo stack.
So, my expectation as a user is to type a run of text that counts as one item on the undo stack. That is until I make a selection change, delete a character, or (potentially) a certain time limit passes, etc.
We can further group the above into different categories of undo and redo behavior:
I can think of three ways to accomplish this.
pendingSnapshot
) and push only the latest version onto the proper undo stack when the run is broken or an undo requested.pendingSnapshot
if it's part of the same run.Obviously the first two options would require a considerable increase in the number of states which are kept in memory.
Is there a reason why the number of five was chosen as a default?
The text was updated successfully, but these errors were encountered: