]> git.lyx.org Git - features.git/commitdiff
Fix regression of 18779013 for \smash
authorGeorg Baum <baum@lyx.org>
Wed, 19 Feb 2014 19:50:57 +0000 (20:50 +0100)
committerGeorg Baum <baum@lyx.org>
Wed, 19 Feb 2014 19:50:57 +0000 (20:50 +0100)
When adding native support for \smash in 18779013 I overlooked that amsmath
redefines \smash to take an optional argument t or b. These optional
arguments are not parsed correctly anymore (bug 8967). This change fixes
the regression, so that \smash with optional argument appears in red, as it
was before th introduction of the native smash inset.
In the future, we should have native support for \smash[t] and \smash[b]
as well, but this would be a file format change (automatic amsmath loading),
and it is too late for 2.1.0.

src/mathed/MathParser.cpp

index ef987789b319a0e7b045d78d3f868eb1fba70e61..317e7b0a73afe1504cd57f4825f0fd9e1da0935d 100644 (file)
@@ -1831,6 +1831,27 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        }
                }
 
+               else if (t.cs() == "smash") {
+                       skipSpaces();
+                       if (nextToken().asInput() == "[") {
+                               // Since the phantom inset cannot handle optional arguments
+                               // we must not create an InsetMathPhantom (bug 8967).
+                               docstring const opt = parse_verbatim_option();
+                               docstring const arg = parse_verbatim_item();
+                               cell->push_back(MathAtom(new MathMacro(buf, t.cs())));
+                               MathData ar;
+                               mathed_parse_cell(ar, '[' + opt + ']', mode_);
+                               cell->append(ar);
+                               ar = MathData();
+                               mathed_parse_cell(ar, '{' + arg + '}', mode_);
+                               cell->append(ar);
+                       }
+                       else {
+                               cell->push_back(createInsetMath(t.cs(), buf));
+                               parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+                       }
+               }
+
 #if 0
                else if (t.cs() == "infer") {
                        MathData ar;