From d9ddc95ab81c420e630c681bc672d3dd4e611a69 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 4 Jul 2010 18:08:14 +0000 Subject: [PATCH] Refine fix for #6595. It turns out that the last empty line is to be 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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index a8213959b8..b4d4102bfb 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -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_; } -- 2.39.2