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
This commit is contained in:
Jean-Marc Lasgouttes 2006-08-17 21:13:15 +00:00
parent 01010f76e8
commit 31f3506938
3 changed files with 29 additions and 3 deletions

View File

@ -1,3 +1,13 @@
2006-08-17 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
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 <lasgouttes@lyx.org>
* math_inset.C (cell): make debug message more explicit.

View File

@ -19,6 +19,7 @@
#include "cursor.h"
#include "debug.h"
#include "funcrequest.h"
#include "undo.h"
#include <boost/assert.hpp>
@ -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;
}

View File

@ -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.