]> git.lyx.org Git - features.git/commitdiff
Position better the cursor after math-display
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 8 Jul 2015 09:01:42 +0000 (11:01 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 9 Jul 2015 10:00:25 +0000 (12:00 +0200)
When the cursor had idx > 0 (since math-display does merging anyways),
reset cursor to the start of the inset. This looks less strange than
setting it at the end.

Now at least the basic case of a displayed equation with cursor
somewhere at top-level is handled correctly.

The math-display lfun operates at top level in the math inset.
Therefore, when the cursor is in an inner inset, it will after the
lfun be moved at top level. Unfortunately, there is no way that I know
f to detect this in Inset::doDispatch.

Even if we could, as things stand, it is difficult to keep the cursor in the
inner inset, especially if the inner inset moves : this happens for
example when moving from eqnarray to inline maths.

Therefore this fix is the best I can think of now.

Fixes part of bug #9664.

src/mathed/InsetMathHull.cpp

index d8850e835ec339e832355a20e6e29c4c640790ee..442d7f3a54cad87c2056ee34df152b36d39cfc13 100644 (file)
@@ -1647,9 +1647,15 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_MATH_DISPLAY: {
                cur.recordUndoInset();
                mutate(type_ == hullSimple ? hullEquation : hullSimple);
-               cur.idx() = 0;
-               cur.pos() = cur.lastpos();
-               //cur.dispatched(FINISHED);
+               // if the cursor is in a cell that got merged, move it to
+               // start of the hull inset.
+               if (cur.idx() > 0) {
+                       cur.idx() = 0;
+                       cur.pos() = 0;
+               }
+               if (cur.pos() > cur.lastpos())
+                       cur.pos() = cur.lastpos();
+
                break;
        }