boolean (@NotNull UndoManagerImpl undoManager, @NotNull Document document) { DocumentReference ref = DocumentReferenceManager.getInstance().create(document); VirtualFile file = ref.getFile(); // Allow undo even from refresh if requested if (file != null && UndoUtil.isForceUndoFlagSet(file)) { return true; } return !UndoManagerImpl.isRefresh() || undoManager.isUndoOrRedoAvailable(ref); }