From: Stefan Schimanski Date: Sat, 9 Feb 2008 22:04:30 +0000 (+0000) Subject: * Finally fix the empty-script removal, i.e. remove empty scripts in X-Git-Tag: 1.6.10~6347 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d78b0692e26f8a41f80cac0aadeb390367603af2;p=features.git * Finally fix the empty-script removal, i.e. remove empty scripts in any case when leaving the script inset. Before there were cases (like when emptying both scripts and then leaving the inset) to leave the script inset such that empty script were kept. * Force a paragraph redraw when removing a script. This will remove the space after an inset which got the scripts removed. Moreover this fixes some assert because the script body might not be in the coordinate cache after the script inset was removed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22907 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp index 3fd94d11d8..2d283696d9 100644 --- a/src/mathed/InsetMathScript.cpp +++ b/src/mathed/InsetMathScript.cpp @@ -664,24 +664,33 @@ bool InsetMathScript::notifyCursorLeaves(Cursor & cur) //LYXERR0("InsetMathScript::notifyCursorLeaves: 1 " << cur); - // remove empty scripts if possible - if (nargs() > 2) { - // Case of two scripts. In this case, 1 = super, 2 = sub - if (cur.idx() == 2 && cell(2).empty()) { + // Remove empty scripts if possible: + + // The case of two scripts, but only one got empty (1 = super, 2 = sub). + // We keep the script inset, but remove the empty script. + if (nargs() > 2 && (!cell(1).empty() || !cell(2).empty())) { + if (cell(2).empty()) { // must be a subscript... cur.recordUndoInset(); removeScript(false); + cur.updateFlags(cur.disp_.update() | Update::SinglePar); return true; - } else if (cur.idx() == 1 && cell(1).empty()) { + } else if (cell(1).empty()) { // must be a superscript... cur.recordUndoInset(); removeScript(true); + cur.updateFlags(cur.disp_.update() | Update::SinglePar); return true; } - } else if (nargs() > 1 && cur.idx() == 1 && cell(1).empty()) { + } + // Now the two suicide cases: + // * we have only one script which is empty + // * we have two scripts which are both empty. + // The script inset is removed completely. + if ((nargs() == 2 && cell(1).empty()) + || (nargs() == 3 && cell(1).empty() && cell(2).empty())) { // could be either subscript or super script cur.recordUndoInset(); - removeScript(cell_1_is_up_); // Let the script inset commit suicide. This is // modelled on Cursor.pullArg(), but tries not to // invoke notifyCursorLeaves again and does not touch @@ -692,6 +701,7 @@ bool InsetMathScript::notifyCursorLeaves(Cursor & cur) tmpcur.pop(); tmpcur.cell().erase(tmpcur.pos()); tmpcur.cell().insert(tmpcur.pos(), ar); + cur.updateFlags(cur.disp_.update() | Update::SinglePar); return true; }