]> git.lyx.org Git - lyx.git/commitdiff
fix nasty crash when selecting with up/down close to super/subcripts
authorAndré Pönitz <poenitz@gmx.net>
Tue, 30 Sep 2003 07:58:03 +0000 (07:58 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 30 Sep 2003 07:58:03 +0000 (07:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7839 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_cursor.C
src/mathed/math_pos.C

index 657d93292335ebc99c8613fb513988496e033a3a..9483dd4eb2bf0596fb64d1db6e8386e83759f73e 100644 (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,
index 15165e9ba3c0cfb0027a4ad60e06242944d894c4..39381c9f23495ccbe8e8ace4a3eeff28936a1482 100644 (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_)