ci_edit icon indicating copy to clipboard operation
ci_edit copied to clipboard

Changes combining after a series of actions

Open aaxu opened this issue 7 years ago • 3 comments

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?

aaxu avatar Dec 13 '17 16:12 aaxu

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?

dschuyler avatar Dec 13 '17 18:12 dschuyler

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.

aaxu avatar Dec 13 '17 18:12 aaxu

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)

aaxu avatar Dec 22 '17 02:12 aaxu