]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_data.C
Make Helge happy: no more crash on arrow up/down in math macro
[lyx.git] / src / mathed / math_data.C
index ffda365de26ed54d09a107b4b2f8566e24ac731e..b26a119a08a38cb869977fd9a51452b9a11edd48 100644 (file)
@@ -221,7 +221,7 @@ namespace {
 bool isInside(DocIterator const & it, MathArray const & ar,
        lyx::pos_type p1, lyx::pos_type p2)
 {
-       for (size_t i = 0; i != it.size(); ++i) {
+       for (size_t i = 0; i != it.depth(); ++i) {
                CursorSlice const & sl = it[i];
                if (sl.inset().inMathed() && &sl.cell() == &ar)
                        return p1 <= sl.pos() && sl.pos() < p2;
@@ -380,8 +380,16 @@ MathArray::size_type MathArray::x2pos(int targetx, int glue) const
                        currx += glue;
                currx += (*it)->width();
        }
+
        if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
                --it;
+       // The below code guarantees that in this slice, the cursor will 
+       // never be on the right edge of an inset after a mouse click.
+       if (it != begin())
+               --it;
+       if (it < end() && (*it)->getChar())
+               ++it;
+               
        return it - begin();
 }