mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
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 empry. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14793 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3826a5c54f
commit
4d55c8b288
@ -19,6 +19,7 @@
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@ -434,10 +435,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())
|
||||
@ -565,14 +566,27 @@ 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;
|
||||
|
Loading…
Reference in New Issue
Block a user