void () { CodeFormatterFacade.FORMATTING_CANCELLED_FLAG.set(true); VirtualFile file = myFile.get(); Document document = myDocument.get(); if (file == null || document == null || myDocumentModificationStampBefore < 0) { return; } FileEditor editor = FileEditorManager.getInstance(myProject).getSelectedEditor(file); if (editor == null) { return; } UndoManager manager = UndoManager.getInstance(myProject); while (manager.isUndoAvailable(editor) && document.getModificationStamp() != myDocumentModificationStampBefore) { manager.undo(editor); } }