Undoable actions

How does IDEA know when and how to undo an action?
Apparently changing a file as part of an action through the VFS does not add
the action in the undo list. How do I create an action that can be undone? I
believe there is no way to get notification that an action was undone so how
does IDEA undo the side effects? Through the LVCS? Anyhow it would be
useful to have a callback on AnAction to get notified when an action is
undone. This would be required to keep external resources in sync.

Jacques


4 comments
Comment actions Permalink

This is very important for me too. I am writing a plugin that creates a few classes and I would like to be able to provide an "undo" for my action but I see no way to tap into this. I saw the interface PsiUndoableAction but could not figure out if that was relevent or how to use it.

Kirk

0
Comment actions Permalink

I am not sure you are aware that has long as you create/update your classes through either the Document (insertString,replaceString,removeString)interface or PSI interace (PsiElementFactory,...) you get undo capability for free. The top level command will become a transaction boundary that you can rollback by doing its undo.
Kind of nice isn't it.
However it does not address side effects outside of IDEA or any actions that are not impacting project files.
I am looking for a standard undo capabilities where action undo themselves instead of the infrastructure. It should not be that hard to do.

Jacques

0
Comment actions Permalink

Thanks for the info. I am seeing the behavior you described now. What threw me is that in Aurora it seems that class creation and deletion is no longer undoable. For example, if I manually create a new class I cannot undo, whereas in 3.0 it will undo creating the class. Same with deleting a class. I presume this is just a temporary bug in Aurora and will be fixed eventually.

Kirk

0

Please sign in to leave a comment.