Position better the cursor after math-display

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.
This commit is contained in:
Jean-Marc Lasgouttes 2015-07-08 11:01:42 +02:00
parent 2a7deb802a
commit 7d018853fc

View File

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