]> git.lyx.org Git - lyx.git/commitdiff
Correctly distinguish LyX macros from those defined in ERT
authorEnrico Forestieri <forenr@lyx.org>
Thu, 15 Sep 2016 22:43:04 +0000 (00:43 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 15 Sep 2016 22:43:04 +0000 (00:43 +0200)
At this time the MacroData of a macro is still uninitialized,
so the macro() method always returns null.

src/Cursor.cpp

index 27c9cd6ac9530f0d0f9cc1eb779a733ac3a77c40..6485fc4a561d684ee9ed28a14664a06257883cb9 100644 (file)
@@ -1426,8 +1426,9 @@ bool Cursor::macroModeClose()
        InsetMathNest * const in = inset().asInsetMath()->asNestInset();
        if (in && in->interpretString(*this, s))
                return true;
-       MathAtom atom = buffer()->getMacro(name, *this, false) ?
-               MathAtom(new MathMacro(buffer(), name)) : createInsetMath(name, buffer());
+       bool const ert_macro = !buffer()->getMacro(name, *this, false);
+       MathAtom atom = ert_macro ? createInsetMath(name, buffer())
+                                 : MathAtom(new MathMacro(buffer(), name));
 
        // try to put argument into macro, if we just inserted a macro
        bool macroArg = false;
@@ -1454,7 +1455,6 @@ bool Cursor::macroModeClose()
        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
            && atom.nucleus()->currentMode() == Inset::MATH_MODE