[LyX/master] Fixup e1be71da5: avoid duplication of layout

Jean-Marc Lasgouttes lasgouttes at lyx.org
Mon Sep 7 11:51:30 UTC 2020


commit 9b18a9b609c0af78b4bb08667fd8e02ebd897d5e
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Mon Sep 7 14:16:47 2020 +0200

    Fixup e1be71da5: avoid duplication of layout
    
    If the containing paragraph has kept its layout, reset the layout of
    the first paragraph of the newly inserted inset.
---
 src/Text3.cpp |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/Text3.cpp b/src/Text3.cpp
index 313be9d..94c6d13 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -293,6 +293,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
 	}
 
 	bool gotsel = false;
+	bool move_layout = false;
 	if (cur.selection()) {
 		if (cmd.action() == LFUN_INDEX_INSERT)
 			copySelectionToTemp(cur);
@@ -303,8 +304,10 @@ static bool doInsertInset(Cursor & cur, Text * text,
 			 * FIXME: this does not work as expected when change tracking is on
 			 *   However, we do not really know what to do in this case.
 			 */
-			if (cur.paragraph().empty() && !inset->forcePlainLayout())
+			if (cur.paragraph().empty() && !inset->forcePlainLayout()) {
 				cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
+				move_layout = true;
+			}
 		}
 		cur.clearSelection();
 		gotsel = true;
@@ -330,6 +333,11 @@ static bool doInsertInset(Cursor & cur, Text * text,
 		inset_text->fixParagraphsFont();
 		cur.pos() = 0;
 		cur.pit() = 0;
+		/* If the containing paragraph has kept its layout, reset the
+		 * layout of the first paragraph of the inset.
+		 */
+		if (!move_layout)
+			cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
 		// FIXME: what does this do?
 		if (cmd.action() == LFUN_FLEX_INSERT)
 			return true;


More information about the lyx-cvs mailing list