On Sun, Apr 09, 2006 at 11:35:08AM +0300, Martin Vermeer wrote: > On Sun, Apr 09, 2006 at 10:36:15AM +0300, Martin Vermeer wrote: > > > > The following can probably be exploited to debug Undo's problems in > > mathed: > > > > 1) Insert a math inset with a 2x2 math array inside. > > 2) Place the cursor in position (2,1), i.e., second row, first column. > > 3) Press Delete. > > > > The second row of the math array will be deleted. > > > > 4) Press Undo (C-z). > > > > You will get the error message > > > > "wrong idx 2, max is 1 at level 3" > > > > which is both right and wrong: Undo has failed to restore the 2x2 > > matrix, where this position would legally exist. > > > > So, Undo doesn't do a proper job here. Repeated undo doesn't help > > either. The second array row is gone and stays gone. > > Correction: the problem is not with undo (wrongly accused ;-/ ) but with > the way the various record methods are used in math. NestInset is not > aware that Delete does some special things inside a math grid. > > The attached fixes the bug at the root cause. > > Does anybody see a problem with this? > > - Martin
I'll commit this to trunk presently. - Martin
Index: math_nestinset.C =================================================================== --- math_nestinset.C (revision 13612) +++ math_nestinset.C (working copy) @@ -621,7 +621,7 @@ void MathNestInset::doDispatch(LCursor & case LFUN_DELETE_WORD_BACKWARD: case LFUN_BACKSPACE: if (cur.pos() == 0) - // delete whole cell + // May affect external cell: recordUndoInset(cur, Undo::ATOMIC); else recordUndo(cur, Undo::ATOMIC); @@ -630,7 +630,11 @@ void MathNestInset::doDispatch(LCursor & case LFUN_DELETE_WORD_FORWARD: case LFUN_DELETE: - recordUndo(cur); + if (cur.pos() == cur.lastpos()) + // May affect external cell: + recordUndoInset(cur, Undo::ATOMIC); + else + recordUndo(cur, Undo::ATOMIC); cur.erase(); break;
pgpO61curgtu6.pgp
Description: PGP signature