Daniel Watkins wrote:
> This stops the crash, but the undo does not work perfectly. If there is a
> blank row at the bottom of the matrix, it is not restored. If there is more
> than one empty row, only the bottom one is removed, but another one is
> removed if the delete/undo is repeated, until there is only one remaining.
> A row with content, or the top row, will stop any more rows disappearing.
>
> Steps to reproduce:
> 1) Create 3x3 matrix.
> 2) Cursor in top-left box.
> 3) Backspace.
> 4) Undo
>
> Result:
> An empty 3x2 matrix is restored.
>
> Expected result:
> An empty 3x3 matrix is restored.

This is a separate bug (# 2067 now). The bug is actually not in undo, but in 
MathGridInset::write. This means that a matrix with several empty rows is 
also exported to LaTeX incorrectly, because the end-of-line command was not 
written for the first empty line.

Patch attached.

Does this look sensible?

Jürgen

P.S.: the context of the changes:

void MathGridInset::write(WriteStream & os) const
{
[...]
        string const s = verboseHLine(rowinfo_[nrows()].lines_);
        if (!s.empty() && s != " ") {
                if (os.fragile())
                        os << "\\protect";
                os << "\\\\" << s;
        }
+       else
+               os << "\\\\";
}
Index: math_gridinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.C,v
retrieving revision 1.168
diff -p -u -r1.168 math_gridinset.C
--- math_gridinset.C	18 Jul 2005 00:09:20 -0000	1.168
+++ math_gridinset.C	3 Oct 2005 07:43:51 -0000
@@ -975,6 +975,8 @@ void MathGridInset::write(WriteStream & 
 			os << "\\protect";
 		os << "\\\\" << s;
 	}
+	else
+		os << "\\\\";
 }
 
 
@@ -1043,7 +1045,7 @@ void MathGridInset::doDispatch(LCursor &
 		// FIXME: We use recordUndoInset when a change reflects more
 		// than one cell, because recordUndo does not work for
 		// multiple cells. Unfortunately this puts the cursor in front
-		// of the inset after undo. This is (especilally for large
+		// of the inset after undo. This is (especially for large
 		// grids) annoying.
 		recordUndoInset(cur);
 		//autocorrect_ = false;

Reply via email to