fix nasty crash when selecting with up/down close to super/subcripts

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7839 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-09-30 07:58:03 +00:00
parent dbd3cb42c5
commit 4dbd6214a9
2 changed files with 26 additions and 24 deletions

View File

@ -936,28 +936,30 @@ bool MathCursor::goUpDown(bool up)
xo = targetx_;
// try neigbouring script insets
// try left
if (hasPrevAtom()) {
MathScriptInset const * p = prevAtom()->asScriptInset();
if (p && p->has(up)) {
--pos();
push(nextAtom());
idx() = up; // the superscript has index 1
pos() = size();
///lyxerr << "updown: handled by scriptinset to the left" << endl;
return true;
if (!selection()) {
// try left
if (hasPrevAtom()) {
MathScriptInset const * p = prevAtom()->asScriptInset();
if (p && p->has(up)) {
--pos();
push(nextAtom());
idx() = up; // the superscript has index 1
pos() = size();
//lyxerr << "updown: handled by scriptinset to the left" << endl;
return true;
}
}
}
// try right
if (hasNextAtom()) {
MathScriptInset const * p = nextAtom()->asScriptInset();
if (p && p->has(up)) {
push(nextAtom());
idx() = up;
pos() = 0;
///lyxerr << "updown: handled by scriptinset to the right" << endl;
return true;
// try right
if (hasNextAtom()) {
MathScriptInset const * p = nextAtom()->asScriptInset();
if (p && p->has(up)) {
push(nextAtom());
idx() = up;
pos() = 0;
//lyxerr << "updown: handled by scriptinset to the right" << endl;
return true;
}
}
}
@ -977,7 +979,7 @@ bool MathCursor::goUpDown(bool up)
// try to find an inset that knows better then we
while (1) {
///lyxerr << "updown: We are in " << *inset() << " idx: " << idx() << endl;
//lyxerr << "updown: We are in " << inset() << " idx: " << idx() << endl;
// ask inset first
if (inset()->idxUpDown(idx(), pos(), up, targetx_)) {
// try to find best position within this inset
@ -987,7 +989,7 @@ bool MathCursor::goUpDown(bool up)
}
// no such inset found, just take something "above"
///lyxerr << "updown: handled by strange case" << endl;
//lyxerr << "updown: handled by strange case" << endl;
if (!popLeft())
return
bruteFind(xo, yo,

View File

@ -80,8 +80,8 @@ bool operator!=(CursorPos const & p, CursorPos const & q)
bool operator<(CursorPos const & p, CursorPos const & q)
{
if (p.inset_ != q.inset_) {
lyxerr << "can't compare cursor and anchor in different insets"
<< endl;
lyxerr << "can't compare cursor and anchor in different insets\n"
<< "p: " << p << '\n' << "q: " << q << endl;
return true;
}
if (p.idx_ != q.idx_)