]> git.lyx.org Git - features.git/commitdiff
Refine fix for #6595. It turns out that the last empty line is to be
authorEnrico Forestieri <forenr@lyx.org>
Sun, 4 Jul 2010 18:08:14 +0000 (18:08 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 4 Jul 2010 18:08:14 +0000 (18:08 +0000)
deleted not only for "array" but also for all inner-hull grid types.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34752 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/MathParser.cpp

index a8213959b87208bddf29c59d2acc5677e20b22ae..b4d4102bfb66840ef7a522393103b062eed90b4b 100644 (file)
@@ -214,7 +214,7 @@ bool addCol(InsetMathGrid & grid, InsetMathGrid::col_type & cellcol)
 
 
 /*!
- * Check wether the last row is empty and remove it if yes.
+ * Check whether the last row is empty and remove it if yes.
  * Otherwise the following code
  * \verbatim
 \begin{array}{|c|c|}
@@ -225,6 +225,8 @@ bool addCol(InsetMathGrid & grid, InsetMathGrid::col_type & cellcol)
  * \endverbatim
  * will result in a grid with 3 rows (+ the dummy row that is always present),
  * because the last '\\' opens a new row.
+ * Note that this is only needed for inner-hull grid types, such as array
+ * or aligned, but not for outer-hull grid types, such as eqnarray or align.
  */
 void delEmptyLastRow(InsetMathGrid & grid)
 {
@@ -241,6 +243,16 @@ void delEmptyLastRow(InsetMathGrid & grid)
 }
 
 
+/*!
+ * Tell whether the environment name corresponds to an inner-hull grid type.
+ */
+bool innerHull(docstring const & name)
+{
+       return name == "array" || name == "cases" || name == "aligned"
+               || name == "alignedat" || name == "gathered" || name == "split";
+}
+
+
 // These are TeX's catcodes
 enum CatCode {
        catEscape,     // 0    backslash
@@ -1244,7 +1256,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        // probably need to refine this test.
                                        // Right now we only have to test for
                                        // single line hull insets.
-                                       if (grid.nrows() > 1 && name == "array")
+                                       if (grid.nrows() > 1 && innerHull(name))
                                                delEmptyLastRow(grid);
                                        return success_;
                                }