[LyX/master] \protect xymatrix in fragile context

Juergen Spitzmueller spitz at lyx.org
Mon Dec 27 10:14:01 UTC 2021


commit 582fe0990f58625824a0e2521dac6905af897d9c
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Mon Dec 27 11:42:30 2021 +0100

    \protect xymatrix in fragile context
    
    (\cprotect'ion not needed then).
---
 src/Paragraph.cpp                |    1 -
 src/mathed/InsetMathXYMatrix.cpp |    2 ++
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 17c68fa..369bda0 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4126,7 +4126,6 @@ bool Paragraph::needsCProtection(bool const fragile) const
 			continue;
 		switch(im->cell(0)[0]->lyxCode()) {
 		case MATH_ENV_CODE:
-		case MATH_XYMATRIX_CODE:
 			// these need cprotection
 			return true;
 		default:
diff --git a/src/mathed/InsetMathXYMatrix.cpp b/src/mathed/InsetMathXYMatrix.cpp
index 7e35fe9..d8f5460 100644
--- a/src/mathed/InsetMathXYMatrix.cpp
+++ b/src/mathed/InsetMathXYMatrix.cpp
@@ -66,6 +66,8 @@ void InsetMathXYMatrix::draw(PainterInfo & pi, int x, int y) const
 void InsetMathXYMatrix::write(TeXMathStream & os) const
 {
 	MathEnsurer ensurer(os);
+	if (os.fragile())
+		os << "\\protect";
 	os << "\\xymatrix";
 	bool open = os.startOuterRow();
 	if (equal_spacing_) {


More information about the lyx-cvs mailing list