[LyX/master] Fix crash related to Cursor::macroModeClose().
Jean-Marc Lasgouttes <[email protected]>
| Newsgroups | gmane.editors.lyx.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit edffc7d6ed372fd3ee2337169470aafb5b18f578 Author: Jean-Marc Lasgouttes <[email protected]> Date: Wed Mar 25 12:33:28 2026 +0100 Fix crash related to Cursor::macroModeClose(). Recipe sent to lyx-devel mailing list: open a new document, press Ctrl+M for creating a math box, write '\alpha' into the box, press right arrow key. What happens here is that, in handling of LFUN_CHAR_FORWARD in InsetMathNest::doDispatch, Cursor::macroModeClose is invoked (which turns \alpha to α) and then the cursor is moved forward. This, in turn, will lead to having the lfun undispatched and turned to LFUN_FINISHED_FORWARD. The consequence is that the flag Update::Force set by macroModeClose is overridden in Cursor::dispatch. The solution used here is to avoid moving the cursor if macroModeClose did something. This is a better behavior anyway. In existing code, if one is in a formula before a character and types "\alpha<right>" the cursor will jump after the character which is after the alpha. This is not nice. Add a note in Cursor::dispatch that resetting update flags may not be a good idea. The fact that this bug is new to 2.5.x is related to less systematic full screen updates in LyX 2.5.x. --- src/Cursor.cpp | 2 ++ src/mathed/InsetMathNest.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index b5daf9c860..cc06268483 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -846,6 +846,8 @@ void Cursor::dispatch(FuncRequest const & cmd0) safe.pos() = safe.lastpos(); } operator=(safe); + // FIXME: should the screen update flags be preserved? After + // all an update may have been requested for a reason. disp_.screenUpdate(Update::None); disp_.dispatched(false); } else { diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index aff39557f0..834b5bfbc3 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -976,10 +976,10 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) // Now that we know exactly what we want to do, let's do it! cur.selHandle(select); cur.clearTargetX(); - cur.macroModeClose(); - // try moving forward or backwards as necessary... - if (!(forward ? cur.mathForward(word) : cur.mathBackward(word))) { - // ... and if movement failed, then finish forward or backwards + // Try in order (1) close macromode and (2) move cursor... + if (!cur.macroModeClose() + && !(forward ? cur.mathForward(word) : cur.mathBackward(word))) { + // ... and both failed, then finish forward or backward // as necessary cmd = FuncRequest(finish_lfun); cur.undispatched(); -- lyx-cvs mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-cvs