[LyX/master] When inserting math inset, put cursor selection in the correct cell

Scott Kostyshak skostysh at lyx.org
Sun Mar 13 20:39:39 UTC 2022


On Thu, Apr 05, 2018 at 11:24:27AM +0200, Jean-Marc Lasgouttes wrote:
> commit 503c7c1688bee80a2c5dc472aaf97fb2aa0391e0
> Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
> Date:   Wed Apr 4 18:24:14 2018 +0200
> 
>     When inserting math inset, put cursor selection in the correct cell
>     
>     The original use case for this bug is entering an overset inset when
>     there is a selection. The expected result was to have the selection
>     pasted in main text, but the result was to have it in the cell.
>     
>     Insets already have idxFirst() that is able to set cursor to the
>     "entry" cell of an inset. This patch introduces firstIdx(), which is
>     the index of this cell and uses it in idxFirst() (idem for
>     lastIdx/idxLast).
>     
>     As a consequence, several instances of idxFirst/idxLast can be removed.
>     
>     Now for the real fix: the two places where the cell in which selection
>     is inserted seem to be:
>     * Cursor::macroModeClose
>     * Cursor::handleNest
>     
>     These two methods are changed to insert material in the entry cell
>     instead of cell 0.
>     
>     idxFirst/Last methods are added to InsetMathRoot and InsetMathStackrel
>     so that the natural entry point is the nucleus of those insets.
>     
>     Finallly, a typo is fixed in InsetMathNest::edit() where enter_front
>     computation was incorrect.
> ---

A git bisect lead me here based on the following:

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 this commit, the selection inside the math inset was preserved.
After this commit, it is lost.

Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20220313/56ef6fcf/attachment.asc>


More information about the lyx-devel mailing list