]> git.lyx.org Git - features.git/blobdiff - src/mathed/MathData.cpp
Fix display and output of math macros with optional arguments
[features.git] / src / mathed / MathData.cpp
index f2100afb34757b57b09f1c7c76ac75b40c0117cd..2a36e551aaebc5dc8a516b1998ae9f61c22325aa 100644 (file)
@@ -659,12 +659,15 @@ void MathData::collectOptionalParameters(Cursor * cur,
                if (operator[](pos)->getChar() != '[')
                        break;
 
-               // found possible optional argument, look for "]"
+               // found possible optional argument, look for pairing "]"
+               int count = 1;
                size_t right = pos + 1;
                for (; right < size(); ++right) {
                        MathAtom & cell = operator[](right);
 
-                       if (cell->getChar() == ']')
+                       if (cell->getChar() == '[')
+                               ++count;
+                       else if (cell->getChar() == ']' && --count == 0)
                                // found right end
                                break;