I've seen these questions, but in my case the equation content is too long to add the text description at the end and it overflows into the margin.
\[
d_i(g_n,\ldots,g_0) =
\begin{cases}
(d_0g_ng_{n-1},g_{n-2},\ldots,g_0),& \text{if $i=0$;}\\
(d_ig_n,\ldots,d_1g_{n-i+1},d_0g_{n-i}g_{n-i-1},g_{n-i-2},\ldots,g_0), &\text{if $i=1,\ldots,n-1$;}\\
(d_ng_n,\ldots,d_1g_1),& \text{if $i=0$}
\end{cases}\\
\]
What I'd like is something similar to would be produced by replacing the one overly long line by the two lines
(d_ig_n,\ldots,d_1g_{n-i+1},d_0g_{n-i}g_{n-i-1},g_{n-i-2},\ldots,g_0), &\\
& \hspace{-10.5ex}\text{if $i=1,\ldots,n-1$;}\
...but this is clearly not the way to do it. I'd also prefer not to break the long equation itself onto two lines, only put the text on the next line. Is there some nice way that will end up with the result that the semicolons are aligned automatically without tweaking the horizontal spacing?
