I do not really understand the parser very well. So here is a simple minded patch. Andre, as you are mentioned as author, does this make sense? With FLAG_ITEM the parser will stop at the closing \end, but ignoring the {sideways}. All the other cases of the \begin handler use the FLAG_END.

Btw, the bug has nothing to do with macros: just type $ \begin{sideways}a\end{sideways}$, select it and press Ctrl-m.

diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index 31a34dd..e14c925 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -1266,7 +1266,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                               << to_utf8(l->inset) << "'." << 
endl;
                                        // create generic environment inset
                                        cell->push_back(MathAtom(new 
InsetMathEnv(name)));
-                                       parse(cell->back().nucleus()->cell(0), 
FLAG_ITEM, mode);
+                                       parse(cell->back().nucleus()->cell(0), 
FLAG_END, mode);
                                }
                        }

@@ -1276,7 +1276,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        << "'" << endl;
                                // create generic environment inset
                                cell->push_back(MathAtom(new 
InsetMathEnv(name)));
-                               parse(cell->back().nucleus()->cell(0), 
FLAG_ITEM, mode);
+                               parse(cell->back().nucleus()->cell(0), 
FLAG_END, mode);
                        }
                }

Stefan

Am 22.02.2008 um 12:18 schrieb Stefan Schimanski:

Looks like a bug in the parser.

Stefan

Am 22.02.2008 um 12:12 schrieb Dominik Böhm:

Hi,

I am not sure if that's a bug or just not supported. That's the reason
why I send this message to the lyx-devel list.

When you create a new math-macro and insert some
"\begin{sideways}#1\end{sideways}", save the file and reload it, LyX
isn't able to load the macro properly. Instead of
"\begin{sideways}#1\end{sideways}" LyX loads
"\begin{sideways}#1\end{sideways}{sideways}". Each time I save and
reload the file, another "{sideways}" gets added.

Please find attached a simple lyx-file that shows the error.

Why is that, does LyX simply not support environments in math-macros?

Best regards and thanks
Dominik
<error-file.lyx>


Reply via email to