ci_edit
ci_edit copied to clipboard
Changes combining after a series of actions
Wasn't really sure how to title this, but consider this situation
- Type out some string all on one line
- Perform a carriage return
- Type some more stuff (which could represent many actions that would occur after the first line has been typed)
- Undo back to before the carriage return
- Type some more stuff (these will be on the same line as the first line)
- Undo
This last undo right now would undo the entire first line. Should we keep it like this, or would it be better to separate the two changes, since there was a gap between them?
Yeah, I think it makes sense to keep the logical break, err, keep it as two undo steps. I can see how/why the code would do that. I can think of brute force ways of coping with it (like keeping a separate flag or inserting markers in the redo chain. Is there an elegant solution?
I was thinking that we could just check if self.redoIndex != len(self.redoChain)
and if so, we do not merge changes. However, our implementation truncates the chain when we add a new change, while we merge with previous actions in compoundChangePush
at the end, so we may end up needing a new instance variable still.
I found a different issue that actually stems from this problem. Lets say you save after typing some string of characters, save, and exit. Open up the file again and type a few more characters. Because the last change was an insertion, the change will be coalesced together. The issue with this is that this makes the program think that the file is not dirty.
This issue should also be fixed if we make a break between time gaps (ie: if we save, set the flag to true, so the next change is not coalesced)