Am Samstag, 8. Januar 2005 21:31 schrieb Andre Poenitz:

> Patch attached. You could commit that if it fixes the problem.

Thanks a lot. It does fix the problem for 

\displaystyle a &= b

but not for

a &= \displaystyle b\\
c

I'll commit the attached modified version unless you find a reason not to 
do so.


Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/ChangeLog lyx-1.4-cvs/src/mathed/ChangeLog
--- lyx-1.4-clean/src/mathed/ChangeLog	2005-01-06 20:28:42.000000000 +0100
+++ lyx-1.4-cvs/src/mathed/ChangeLog	2005-01-09 11:58:54.000000000 +0100
@@ -1,3 +1,8 @@
+2005-01-09  Georg Baum  <[EMAIL PROTECTED]>
+
+	* math_parser.C (parse1): handle style commands that are not inside
+	a {} pair, fixes bug 1459 (from André)
+
 2005-01-03  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* math_decorationinset.C (ams, validate): new methods. Require
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/math_parser.C lyx-1.4-cvs/src/mathed/math_parser.C
--- lyx-1.4-clean/src/mathed/math_parser.C	2005-01-08 11:15:02.000000000 +0100
+++ lyx-1.4-cvs/src/mathed/math_parser.C	2005-01-09 11:58:07.000000000 +0100
@@ -191,7 +191,8 @@ inline CatCode catcode(unsigned char c)
 
 
 enum {
-	FLAG_BRACE_LAST = 1 << 1,  //  last closing brace ends the parsing
+	FLAG_ALIGN      = 1 << 0,  //  next & or \\ ends the parsing process
+	FLAG_BRACE_LAST = 1 << 1,  //  next closing brace ends the parsing
 	FLAG_RIGHT      = 1 << 2,  //  next \\right ends the parsing process
 	FLAG_END        = 1 << 3,  //  next \\end ends the parsing process
 	FLAG_BRACK_LAST = 1 << 4,  //  next closing bracket ends the parsing
@@ -757,9 +758,10 @@ void Parser::parse1(MathGridInset & grid
 		else if (t.cat() == catAlign) {
 			//lyxerr << " column now " << (cellcol + 1)
 			//       << " max: " << grid.ncols() << endl;
+			if (flags & FLAG_ALIGN)
+				return;
 			if (addCol(grid, cellcol))
-				cell = &grid.cell(grid.index(cellrow,
-				                             cellcol));
+				cell = &grid.cell(grid.index(cellrow, cellcol));
 		}
 
 		else if (t.cat() == catSuper || t.cat() == catSub) {
@@ -917,6 +919,8 @@ void Parser::parse1(MathGridInset & grid
 		}
 
 		else if (t.cs() == "\\") {
+			if (flags & FLAG_ALIGN)
+				return;
 			if (addRow(grid, cellrow, getArg('[', ']'))) {
 				cellcol = 0;
 				if (grid.asHullInset())
@@ -1210,25 +1214,35 @@ void Parser::parse1(MathGridInset & grid
 			if (l) {
 				if (l->inset == "font") {
 					cell->push_back(createMathInset(t.cs()));
-					parse(cell->back().nucleus()->cell(0), FLAG_ITEM, asMode(mode, l->extra));
+					parse(cell->back().nucleus()->cell(0),
+						FLAG_ITEM, asMode(mode, l->extra));
 				}
 
 				else if (l->inset == "oldfont") {
 					cell->push_back(createMathInset(t.cs()));
-					parse(cell->back().nucleus()->cell(0), flags, asMode(mode, l->extra));
-					return;
+					parse(cell->back().nucleus()->cell(0),
+						flags | FLAG_ALIGN, asMode(mode, l->extra));
+					if (prevToken().cat() != catAlign &&
+					    prevToken().cs() != "\\")
+						return;
+					putback();
 				}
 
 				else if (l->inset == "style") {
 					cell->push_back(createMathInset(t.cs()));
-					parse(cell->back().nucleus()->cell(0), flags, mode);
-					return;
+					parse(cell->back().nucleus()->cell(0),
+						flags | FLAG_ALIGN, mode);
+					if (prevToken().cat() != catAlign &&
+					    prevToken().cs() != "\\")
+						return;
+					putback();
 				}
 
 				else {
 					MathAtom at = createMathInset(t.cs());
 					for (MathInset::idx_type i = 0; i < at->nargs(); ++i)
-						parse(at.nucleus()->cell(i), FLAG_ITEM, asMode(mode, l->extra));
+						parse(at.nucleus()->cell(i),
+							FLAG_ITEM, asMode(mode, l->extra));
 					cell->push_back(at);
 				}
 			}

Reply via email to