Problem with running write action in popup callback


I have an IntentionAction. In the invoke() method I do some code modification, namely something.getModifierList().addAnnotation(aString). This works fine, until I try to create a popup using PopupChooserBuilder and call addAnnotation in the callback. I tried wrapping it in Application.runWriteAction(), which must be called from the event dispatch thread, so I'm wrapping runWriteAction in Application.invokeLater(). This works, but the change cannot be undone, when I click on Undo, I get a message that the last action cannot be undone. This doesn't happen when I don't use the popup and call addAnnotation() directly in my action's invoke() method. How can I make this work correctly?

1 comment
Comment actions Permalink

Are you also wrapping your modification in a Command? You need to do this in order for undo to work. (Use the WriteCommandAction class to do both at the same time.)


Please sign in to leave a comment.