]> git.lyx.org Git - features.git/commitdiff
Avoid inserting spurious \text insets in mathed
authorEnrico Forestieri <forenr@lyx.org>
Thu, 15 Sep 2016 22:37:04 +0000 (00:37 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 15 Sep 2016 22:37:04 +0000 (00:37 +0200)
This amends 5cdbaf51.

src/Cursor.cpp

index 64d7ad3e5e833705dae3d7c31b8597f17c8fa7a9..27c9cd6ac9530f0d0f9cc1eb779a733ac3a77c40 100644 (file)
@@ -1449,6 +1449,11 @@ bool Cursor::macroModeClose()
        else if (atom.nucleus()->nargs() > 0)
                atom.nucleus()->cell(0).append(selection);
 
+       MathWordList const & words = mathedWordList();
+       MathWordList::const_iterator it = words.find(name);
+       bool keep_mathmode = it != words.end() && (it->second.inset == "font"
+                                               || it->second.inset == "oldfont"
+                                               || it->second.inset == "mbox");
        bool ert_macro = atomAsMacro && !atomAsMacro->macro();
 
        if (in && in->currentMode() == Inset::TEXT_MODE
@@ -1460,7 +1465,7 @@ bool Cursor::macroModeClose()
                posForward();
        } else if (in && in->currentMode() == Inset::MATH_MODE
                   && atom.nucleus()->currentMode() == Inset::TEXT_MODE
-                  && name != from_ascii("text")) {
+                  && !keep_mathmode) {
                MathAtom at = createInsetMath("text", buffer());
                at.nucleus()->cell(0).push_back(atom);
                niceInsert(at);