From 7d018853fca43fd16f6df3d27a3311d37d9e5ef4 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 8 Jul 2015 11:01:42 +0200 Subject: [PATCH] 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. --- src/mathed/InsetMathHull.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index d8850e835e..442d7f3a54 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -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; } -- 2.39.2