[Tex/LaTex] Prevent linebreak before enumerate

#enumerateline-breaking

I switched from a proof environment to a custom one, if I begin the custom environment with an enumerate, there is a linebreak that I'd like to prevent. The MWE shows the difference between the proof environment and ex. I tried playing with spacings, and /nobreak, to no avail.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{amsmath,amsfonts}

%% Packages
\usepackage{amsmath,amsfonts}
\usepackage{amsthm}
\usepackage[matha,mathb]{mathabx}
\usepackage[shortlabels]{enumitem}

\usepackage[french]{babel} % load last

%% Custom environments/macros
\newcounter{exnum}[section]
\newenvironment{ex}
           {\stepcounter{exnum}\paragraph{Exercice \thesection.\theexnum.}}
           {\hfill\(\Box\)}

\begin{document}

\section{Section 1}
\begin{ex}
  \begin{enumerate}[(a),wide=0pt]
    \item foo
  \end{enumerate}
\end{ex}

\begin{proof}
  \begin{enumerate}[(a),wide=0pt]
    \item foo
  \end{enumerate}
\end{proof}

\end{document}

Best Answer

Is this an acceptable solution? The line is not being broken after the item in the trivlist (actually, the solution is stolen from the amsthm)

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{amsmath,amsfonts}

%% Packages
\usepackage{amsmath,amsfonts}
\usepackage{amsthm}
\usepackage[matha,mathb]{mathabx}
\usepackage[shortlabels]{enumitem}

\usepackage[french]{babel} % load last

%% Custom environments/macros
\newcounter{exnum}[section]

\newenvironment{ex}
       {\stepcounter{exnum}%
        \trivlist\item[\bfseries Exercice \thesection.\theexnum.]\ignorespaces}
       {\hfill\(\Box\)\endtrivlist}

\begin{document}

\section{Section 1}
\begin{ex}
  \begin{enumerate}[(a),wide=0pt]
  \item foo
  \end{enumerate}
\end{ex}

\end{document}
Related Question