Keeping document history and jump list in sync #13539
-
I discovered the cause of the crash in #13480 and I believe some of the crashes in #12582. When in insert mode, changes are not saved to the history until insert mode is exited. If a jump is pushed to the jump list while in insert mode, it is pushed with the current document state, which is different than what the document history is aware of. This causes a desynchronization between the document history and jump that is stored. When the document history is updated after exiting insert mode, it attempts to update the jumps in the jump list, causing a crash due to the difference between the states. The current solution I am working on is to constantly update the history in insert mode and maintain a "temporary" revision at the end of the history that is updated until insert mode is exited. At that point I "cement" it into the history and if we reenter insert mode, we create a new "temporary" revision. I don't love this solution. My implementation feels messy and hacky at best. I'm looking for ideas to create a better answer to this problem. If not a different solution, then maybe a better way to implement it. Thanks 😊 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Kakoune's codebase should be a good reference for this. It has similar concepts about transactions and undo checkpoints - what it calls undo groups. I only looked into #13480 briefly so far but it seems like we need to be committing undo checkpoints in many more situations, like while moving around and especially by switching windows with the mouse. For movement within the same buffer we may just need to add undo checkpoints but when switching windows we should most likely switch back to normal mode first. (Also see #5632 and #11062) |
Beta Was this translation helpful? Give feedback.
Kakoune's codebase should be a good reference for this. It has similar concepts about transactions and undo checkpoints - what it calls undo groups. I only looked into #13480 briefly so far but it seems like we need to be committing undo checkpoints in many more situations, like while moving around and especially by switching windows with the mouse. For movement within the same buffer we may just need to add undo checkpoints but when switching windows we should most likely switch back to normal mode first. (Also see #5632 and #11062)