commit 324b828717cb774f2ddbc3aab6f48827743d13fb
Author: Enrico Forestieri <[email protected]>
Date:   Tue Dec 18 11:39:21 2018 +0100

    Fix bug 11346
    
    Enclose in braces an optional argument of a math macro when it
    starts with an incomplete script inset or ends with a delimiter
    size-modifier macro.
    
    (cherry picked from commit 2dcb73002666001ff55067abab05f6ab4a5760d9)
---
 src/mathed/InsetMathMacro.cpp |   18 +++++++++++++++++-
 status.23x                    |    2 ++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 6685628..f37b73b 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -15,6 +15,7 @@
 #include "InsetMathMacro.h"
 
 #include "InsetMathChar.h"
+#include "InsetMathScript.h"
 #include "MathCompletionList.h"
 #include "MathExtern.h"
 #include "MathFactory.h"
@@ -1106,7 +1107,22 @@ void InsetMathMacro::write(WriteStream & os) const
        // print out optionals
        for (i=0; i < cells_.size() && i < emptyOptFrom; ++i) {
                first = false;
-               os << "[" << cell(i) << "]";
+               // For correctly parsing it when a document is reloaded, we
+               // need to enclose an optional argument in braces if it starts
+               // with a script inset with empty nucleus or ends with a
+               // delimiter-size-modifier macro (see #10497 and #11346)
+               bool braced = false;
+               size_type last = cell(i).size() - 1;
+               if (cell(i)[last].nucleus()->asUnknownInset()) {
+                       latexkeys const * l = 
in_word_set(cell(i)[last].nucleus()->name());
+                       braced = (l && l->inset == "big");
+               } else if (cell(i)[0].nucleus()->asScriptInset()) {
+                       braced = 
cell(i)[0].nucleus()->asScriptInset()->nuc().empty();
+               }
+               if (braced)
+                       os << "[{" << cell(i) << "}]";
+               else
+                       os << "[" << cell(i) << "]";
        }
 
        // skip the tailing empty optionals
diff --git a/status.23x b/status.23x
index 0ffc423..9680d6f 100644
--- a/status.23x
+++ b/status.23x
@@ -57,6 +57,8 @@ What's new
 - Fix problems with non-ASCII characters in path with recent LaTeX versions
   (bug 11146).
 
+- Fix parsing of math-macro optional arguments after save-reopen (bug 11346).
+
 
 * USER INTERFACE
 

Reply via email to