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 <Shift> + L three times. This will select the entire math inset
   (as expected).
5. Press <Shift> + 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.
This commit is contained in:
Jean-Marc Lasgouttes 2022-03-17 16:42:39 +01:00
parent b9ca608c2f
commit 307a2f91ad

View File

@ -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.