Home Download Buy Blog Forum Support

Detect it's whether a Undo or a Redo command in on_modified?

Detect it's whether a Undo or a Redo command in on_modified?

Postby seanliang on Tue Jul 03, 2012 5:54 am

I want to make my plugin transparent to end user like this:
Code: Select all
def on_modified(self, view):
    command = view.command_history(0)
    if command[0] == 'my_command':
        if _IT_IS_UNDO_:
            view.run_command('undo')
        elif _IT_IS_REDO_:
            view.run_command('redo')

But the Undo and Redo commands don't appear in command_history(), so how can I know is it a undo or redo command in on_modified?

Thanks for helping.
seanliang
 
Posts: 9
Joined: Tue Jun 19, 2012 7:58 am

Re: Detect it's whether a Undo or a Redo command in on_modified?

Postby adzenith on Thu Jul 05, 2012 5:41 pm

In my Elastic Tabstops plugin (https://github.com/SublimeText/ElasticTabstops) I actually overrode undo and redo because I couldn't figure out how else to do it. This was before view.command_history existed, though, so there may be a better way now. Let us know if you get something workable!
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests