From c94c85689a2014686d8d81199278dd323efc7463 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Mon, 10 Jan 2005 08:38:28 +0000 Subject: [PATCH] fix bug 1459 (with help from Andre) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9459 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 5 +++++ src/mathed/math_parser.C | 32 +++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 64725a9113..7ba0474230 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2005-01-09 Georg Baum + + * math_parser.C (parse1): handle style commands that are not inside + a {} pair, fixes bug 1459 (from André) + 2005-01-03 Jean-Marc Lasgouttes * math_decorationinset.C (ams, validate): new methods. Require diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 4f1303362d..9bf89d8e08 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -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, unsigned flags, 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, unsigned flags, } 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, unsigned flags, 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); } } -- 2.39.2