From 31f350693834fb662ba5b8552d530bd2b6b0d076 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 17 Aug 2006 21:13:15 +0000 Subject: [PATCH] Fix bug 2727. * math_scriptinset.C (notifyCursorLeaves): call recordUndoInset before deleting a cell; if the nucleus does not have scripts anymore, delete it and replace it by its contents at enclosing level. (write): output scripts even when they are empty. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@14794 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 10 ++++++++++ src/mathed/math_scriptinset.C | 20 +++++++++++++++++--- status.14x | 2 ++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index cd2daf5cd4..a9027653c8 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,13 @@ +2006-08-17 Jean-Marc Lasgouttes + + Fix bug 2727. + + * math_scriptinset.C (notifyCursorLeaves): call recordUndoInset + before deleting a cell; if the nucleus does not have scripts + anymore, delete it and replace it by its contents at enclosing + level. + (write): output scripts even when they are empty. + 2006-08-17 Jean-Marc Lasgouttes * math_inset.C (cell): make debug message more explicit. diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index f613014bb4..a834c9e3db 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -19,6 +19,7 @@ #include "cursor.h" #include "debug.h" #include "funcrequest.h" +#include "undo.h" #include @@ -432,10 +433,10 @@ void MathScriptInset::write(WriteStream & os) const os << "{}"; } - if (hasDown() && down().size()) + if (hasDown() /*&& down().size()*/) os << "_{" << down() << '}'; - if (hasUp() && up().size()) + if (hasUp() /*&& up().size()*/) os << "^{" << up() << '}'; if (lock_ && !os.latex()) @@ -563,15 +564,28 @@ void MathScriptInset::notifyCursorLeaves(LCursor & cur) // Case of two scripts. In this case, 1 = super, 2 = sub if (cur.idx() == 2 && cell(2).empty()) { // must be a subscript... + recordUndoInset(cur); removeScript(false); } else if (cur.idx() == 1 && cell(1).empty()) { // must be a superscript... + recordUndoInset(cur); removeScript(true); } } else if (nargs() > 1 && cur.idx() == 1 && cell(1).empty()) { // could be either subscript or super script + recordUndoInset(cur); removeScript(cell_1_is_up_); -} + // Let the script inset commit suicide. This is + // modelled on LCursor.pullArg(), but tries not to + // invoke notifyCursorLeaves again and does not touch + // cur (since the top slice will be deleted + // afterwards)) + MathArray ar = cell(0); + LCursor tmpcur = cur; + tmpcur.pop(); + tmpcur.cell().erase(tmpcur.pos()); + tmpcur.cell().insert(tmpcur.pos(), ar); + } //lyxerr << "MathScriptInset::notifyCursorLeaves: 2 " << cur << endl; } diff --git a/status.14x b/status.14x index 7704d577f2..8f7ce57a9c 100644 --- a/status.14x +++ b/status.14x @@ -69,6 +69,8 @@ What's new - Fix lockup when accepting a change in a text inset (bug 2510). +- Fix crash when undoing super/subscript deletion (bug 2727). + - Fix editing of document while Error List dialog is open (bug 2179). - improve position of cursor after undo.