[LyX/2.4.x] Fix faulty undo recording

Jean-Marc Lasgouttes lasgouttes at lyx.org
Thu Jul 18 21:48:08 UTC 2024


commit e57ccede186fa3705578a4908cbf8f96f5b9f5b5
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Tue Jul 16 15:43:11 2024 +0200

    Fix faulty undo recording
    
    The recordUndo() call is very wrong, since we may be inserting over a
    selection covering several paragraphs (undo itself works at paragraph
    granularity).
    
    recordUndoSelection() is the right operation in this case. It is
    equivalent to recordUndo() when there is no selection.
    
    (cherry picked from commit 82f387dabc2b18de6a9917192f4304e92bff8bc1)
---
 src/Text.cpp | 2 +-
 status.24x   | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index d314c251ae..767117a33a 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -3600,7 +3600,7 @@ bool doInsertInset(Cursor & cur, Text * text,
 	if (InsetCollapsible * ci = inset->asInsetCollapsible())
 		ci->setButtonLabel();
 
-	cur.recordUndo();
+	cur.recordUndoSelection();
 	if (cmd.action() == LFUN_ARGUMENT_INSERT) {
 		bool cotextinsert = false;
 		InsetArgument * const ia = static_cast<InsetArgument *>(inset);
diff --git a/status.24x b/status.24x
index 8e6a63cb9c..42df3bb1fe 100644
--- a/status.24x
+++ b/status.24x
@@ -67,6 +67,8 @@ What's new
 
 * INTERNALS
 
+- Fix possible crash in undo code after inserting note inset over a multi-paragraph
+  selection.
 
 
 * DOCUMENTATION AND LOCALIZATION


More information about the lyx-cvs mailing list