From 4dbd6214a95f908f33698d86eef059165652720c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 30 Sep 2003 07:58:03 +0000 Subject: [PATCH] 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 --- src/mathed/math_cursor.C | 46 +++++++++++++++++++++------------------- src/mathed/math_pos.C | 4 ++-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 657d932923..9483dd4eb2 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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, diff --git a/src/mathed/math_pos.C b/src/mathed/math_pos.C index 15165e9ba3..39381c9f23 100644 --- a/src/mathed/math_pos.C +++ b/src/mathed/math_pos.C @@ -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_) -- 2.39.5