]> git.lyx.org Git - features.git/blobdiff - src/mathed/MathMacro.cpp
Implement the suggestion by Andre'
[features.git] / src / mathed / MathMacro.cpp
index 339719483b89e533a83743e527165d4a5555ae7e..2c9aff1f0d6e3f03ab1f3a26a4cd3390a6f2842e 100644 (file)
@@ -655,27 +655,12 @@ bool MathMacro::folded() const
 
 void MathMacro::write(WriteStream & os) const
 {
-       bool brace = os.pendingBrace();
-        os.pendingBrace(false);
-       if (os.latex()) {
-               if (os.textMode() && macro_) {
-                       // This is for sure a math macro
-                       os << "\\ensuremath{";
-                       os.textMode(false);
-                       brace = true;
-               } else if (brace && !macro_) {
-                       // Cannot tell, so don't mess with the mode
-                       os << '}';
-                       os.textMode(true);
-                       brace = false;
-               }
-        }
+       MathEnsurer ensurer(os, macro_ != 0, true);
 
        // non-normal mode
        if (displayMode_ != DISPLAY_NORMAL) {
                os << "\\" << name();
                os.pendingSpace(true);
-               os.pendingBrace(brace);
                return;
        }
 
@@ -722,8 +707,6 @@ void MathMacro::write(WriteStream & os) const
        // add space if there was no argument
        if (first)
                os.pendingSpace(true);
-
-       os.pendingBrace(brace);
 }