void () { UIUtil.invokeAndWaitIfNeeded(() -> { final TestDialog oldTestDialog = TestDialogManager.setTestDialog(TestDialog.OK); try { UndoManager undoManager = UndoManager.getInstance(getProject()); TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(getEditor()); undoManager.undo(textEditor); } finally { TestDialogManager.setTestDialog(oldTestDialog); } }); }