]> git.lyx.org Git - features.git/commitdiff
Make InsetMathNest::editXY more robust
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 24 Feb 2017 22:58:53 +0000 (23:58 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 13 Mar 2017 10:44:22 +0000 (11:44 +0100)
If no reasonable cell has been found to put the cursor in (maybe
because the cell exist but is not in the cache), exit gracefully.

Fixes bug #10520

src/mathed/InsetMathNest.cpp

index 1f0adda5045a15428e02745687eeed430d2c8dfc..596e32aa006e9e2ddb413732fb77a2147cbdf7c9 100644 (file)
@@ -1495,7 +1495,7 @@ void InsetMathNest::edit(Cursor & cur, bool front, EntryDirection entry_from)
 
 Inset * InsetMathNest::editXY(Cursor & cur, int x, int y)
 {
-       int idx_min = 0;
+       int idx_min = -1;
        int dist_min = 1000000;
        for (idx_type i = 0, n = nargs(); i != n; ++i) {
                int const d = cell(i).dist(cur.bv(), x, y);
@@ -1504,6 +1504,9 @@ Inset * InsetMathNest::editXY(Cursor & cur, int x, int y)
                        idx_min = i;
                }
        }
+       if (idx_min == -1)
+               return this;
+
        MathData & ar = cell(idx_min);
        cur.push(*this);
        cur.idx() = idx_min;