This is a slightly tweaked version of Joao Luis's patch.

It looks ok and seems to work. It only affects mathed's numbering of
multline and gather environment which was broken, so things can't get worse
even if I overlooked something.

Ok, Lars?

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)
Index: math_hullinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.C,v
retrieving revision 1.65
diff -u -p -r1.65 math_hullinset.C
--- math_hullinset.C    16 Dec 2002 13:40:02 -0000      1.65
+++ math_hullinset.C    7 Jan 2003 08:17:38 -0000
@@ -358,7 +358,8 @@ void MathHullInset::header_write(WriteSt
                        os << "\\[\n";
        }
 
-       else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign")
+       else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
+                || type_ == "gather" || type_ == "multline")
                        os << "\\begin{" << type_ << star(n) << "}\n";
 
        else if (type_ == "alignat" || type_ == "xalignat")
@@ -369,9 +370,6 @@ void MathHullInset::header_write(WriteSt
                os << "\\begin{" << type_ << '}'
                  << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
 
-       else if (type_ == "multline" || type_ == "gather")
-               os << "\\begin{" << type_ << "}\n";
-
        else
                os << "\\begin{unknown" << star(n) << '}';
 }
@@ -394,10 +392,11 @@ void MathHullInset::footer_write(WriteSt
                        os << "\\]\n";
 
        else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
-            || type_ == "alignat" || type_ == "xalignat")
-               os << "\\end{" << type_ << star(n) << "}\n";
+                || type_ == "alignat" || type_ == "xalignat"
+                || type_ == "gather" || type_ == "multline")
+               os << "\\end{" << type_ << star(n) << "}\n";
 
-       else if (type_ == "xxalignat" || type_ == "multline" || type_ == "gather")
+       else if (type_ == "xxalignat")
                os << "\\end{" << type_ << "}\n";
 
        else
@@ -627,7 +626,7 @@ string MathHullInset::eolString(row_type
        if (numberedType()) {
                if (!label_[row].empty() && !nonum_[row])
                        res += "\\label{" + label_[row] + '}';
-               if (nonum_[row])
+               if (nonum_[row] && (type_ != "multline"))
                        res += "\\nonumber ";
        }
        return res + MathGridInset::eolString(row, fragile);
@@ -766,8 +765,11 @@ MathInset::result_type MathHullInset::di
                        if (display()) {
                                //bv->lockedInsetStoreUndo(Undo::INSERT);
                                bool old = numberedType();
-                               for (row_type row = 0; row < nrows(); ++row)
-                                       numbered(row, !old);
+                               if (type_ == "multline")
+                                       numbered(nrows() - 1, !old);
+                               else
+                                       for (row_type row = 0; row < nrows(); ++row)
+                                               numbered(row, !old);
                                //bv->owner()->message(old ? _("No number") : 
_("Number"));
                                //updateLocal(bv, true);
                        }
@@ -775,16 +777,17 @@ MathInset::result_type MathHullInset::di
 
                case LFUN_MATH_NONUMBER:
                        if (display()) {
+                               row_type r = (type_ == "multline") ? nrows() - 1 : 
+row(idx);
                                //bv->lockedInsetStoreUndo(Undo::INSERT);
-                               bool old = numbered(row(idx));
+                               bool old = numbered(r);
                                //bv->owner()->message(old ? _("No number") : 
_("Number"));
-                               numbered(row(idx), !old);
+                               numbered(r, !old);
                                //updateLocal(bv, true);
                        }
                        return DISPATCHED;
 
                case LFUN_INSERT_LABEL: {
-                       row_type r = row(idx);
+                       row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
                        string old_label = label(r);
                        string new_label = cmd.argument;
 

Reply via email to