From 307a2f91ada54af85bfc70d35bd42a61a49de8ef Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 17 Mar 2022 16:42:39 +0100 Subject: [PATCH] Revert part of 503c7c16: InsetMathNest:edit resets anchor. Fixes bug reported here: https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg217265.html 1. Start a new document. 2. Start a math inset and inside put "1+2". 3. Put the cursor to the right of "+". 4. Press + L three times. This will select the entire math inset (as expected). 5. Press + R. Before 503c7c16, the selection inside the math inset was preserved. After 503c7c16, it is lost. The problem is that InsetMathNest does too much for our needs and resets the anchor (why, I do not know). Therefore, it is better to duplicate the code. --- src/mathed/InsetMathHull.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 8fd2bdd24a..8b63c73f8d 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -2254,7 +2254,10 @@ void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg) void InsetMathHull::edit(Cursor & cur, bool front, EntryDirection entry_from) { - InsetMathNest::edit(cur, front, entry_from); + cur.push(*this); + bool enter_front = (entry_from == Inset::ENTRY_DIRECTION_LEFT || + (entry_from == Inset::ENTRY_DIRECTION_IGNORE && front)); + enter_front ? idxFirst(cur) : idxLast(cur); // The inset formula dimension is not necessarily the same as the // one of the instant preview image, so we have to indicate to the // BufferView that a metrics update is needed.