]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathParser.cpp
Preserve \inputencoding value when switching to non-TeX fonts.
[lyx.git] / src / mathed / MathParser.cpp
index 8539ab66194dd9121d983c642ef207dfd664defa..3449cff5ac426fe85eb8f5750a716e68a6314878 100644 (file)
@@ -942,27 +942,11 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        cell->push_back(MathAtom(new InsetMathSpace(string(1, t.character()), "")));
 
                else if (t.cat() == catBegin) {
-                       bool const inbraces = nextToken().cat() == catBegin ||
-                               (!cell->empty() && cell->back()->asMacro());
                        MathData ar;
                        parse(ar, FLAG_BRACE_LAST, mode);
                        // do not create a BraceInset if they were written by LyX
                        // this helps to keep the annoyance of  "a choose b"  to a minimum
-                       InsetMathMacro const * ma = !inbraces && ar.size() ? ar[0]->asMacro() : 0;
-                       InsetMathChar const * mc = ma && ar.size() > 1 ? ar[1]->asCharInset(): 0;
-                       bool braced = mc && mc->getChar() == '[';
-                       // If this is a macro, it may have optional
-                       // arguments, even if only defaults are used.
-                       // In this case, there is no following '['.
-                       if (!inbraces && !braced && ma && buf) {
-                               if (mode_ & Parse::TRACKMACRO)
-                                       braced = buf->usermacros_with_opts.count(ma->name());
-                               else {
-                                       MacroData const * md = buf->getMacro(ma->name(), false);
-                                       braced = md && md->optionals();
-                               }
-                       }
-                       if ((ar.size() == 1 && ar[0]->extraBraces()) || braced)
+                       if (ar.size() == 1 && ar[0]->extraBraces())
                                cell->append(ar);
                        else
                                cell->push_back(MathAtom(new InsetMathBrace(ar)));
@@ -1150,11 +1134,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                name, nargs, optionals, MacroTypeNewcommand,
                                optionalValues, def, display)));
 
-                       if (buf && (mode_ & Parse::TRACKMACRO)) {
+                       if (buf && (mode_ & Parse::TRACKMACRO))
                                buf->usermacros.insert(name);
-                               if (optionals)
-                                       buf->usermacros_with_opts.insert(name);
-                       }
                }
 
                else if (t.cs() == "newcommandx" ||
@@ -1274,11 +1255,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                name, nargs, optionals, MacroTypeNewcommandx,
                                optionalValues, def, display)));
 
-                       if (buf && (mode_ & Parse::TRACKMACRO)) {
+                       if (buf && (mode_ & Parse::TRACKMACRO))
                                buf->usermacros.insert(name);
-                               if (optionals)
-                                       buf->usermacros_with_opts.insert(name);
-                       }
                }
 
                else if (t.cs() == "(") {
@@ -1626,7 +1604,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                docstring const halign = parse_verbatim_item();
                                cell->push_back(MathAtom(new InsetMathArray(buf, name,
                                        InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
-                               parse2(cell->back(), FLAG_END, mode, false);
+                               parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, false);
                        }
 
                        else if (name == "tabular") {
@@ -2103,7 +2081,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                                        Encodings::MATH_CMD | Encodings::TEXT_CMD,
                                                        is_combining, termination);
                                        }
-                                       if (c) {
+                                       if (c && buf->params().encoding().encodable(c)) {
                                                if (termination) {
                                                        if (nextToken().cat() == catBegin) {
                                                                getToken();