Calling view.run_command(‘redo’) inside of an edit in an on_modified callback (i.e. between view.begin_edit and view.end_edit), and then making a change and hitting undo twice crashes Sublime. I haven’t looked to see if it happens in more cases than this.
[code]class Redo(sublime_plugin.EventListener):
pending = 0
def on_modified(self, view):
if self.pending == 1:
return
self.pending = 1
try:
edit = view.begin_edit()
view.run_command(‘redo’)
finally:
view.end_edit(edit)
self.pending = 0 [/code]
Save this code as a plugin, edit a buffer, and hit undo twice.
I ran into this because I’m trying to add to a closed edit—i.e., when the user types something, I want to modify the buffer, but I want to do it in such a way that hitting undo once will undo both my changes and their changes. I tried to call “undo”, and then start an edit and call “redo” and make my changes before closing the edit, and that’s when I ran into this issue.