[LyX/master] Check layout type when inserting inset over selection

Jean-Marc Lasgouttes lasgouttes at lyx.org
Mon Jan 24 17:54:07 UTC 2022


commit 2da183bf4f69847e30c9c9ab8a32548432a8a8b1
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Mon Jan 24 19:19:46 2022 +0100

    Check layout type when inserting inset over selection
    
    When inserting inset over a selection, the layout is transferred if
    the inset covers full paragraphs.
    
    This is not the right policy in the case of environments. Until proper
    code is written and tested, limit ourselves to command layouts.
    
    Fixes bug #12251.
---
 src/Text3.cpp |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/Text3.cpp b/src/Text3.cpp
index a87169b..529e756 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -299,8 +299,11 @@ static bool doInsertInset(Cursor & cur, Text * text,
 			 * paragraph and the inset allows setting layout
 			 * FIXME: this does not work as expected when change tracking is on
 			 *   However, we do not really know what to do in this case.
+			 * FIXME: figure out a good test in the environment case (see #12251).
 			 */
-			if (cur.paragraph().empty() && !inset->forcePlainLayout()) {
+			if (cur.paragraph().layout().isCommand()
+			     && cur.paragraph().empty()
+			     && !inset->forcePlainLayout()) {
 				cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
 				move_layout = true;
 			}


More information about the lyx-cvs mailing list