]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetFlex.cpp
Typo
[features.git] / src / insets / InsetFlex.cpp
index e6076102f687ce9c428dc9c8574e68442653e307..30ed7bf04586c30fb6c99fbb980859fdb6f7c53e 100644 (file)
@@ -24,6 +24,7 @@
 #include "ParIterator.h"
 #include "TextClass.h"
 
+#include "support/debug.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
@@ -149,11 +150,34 @@ void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
        docstring custom_label = translateIfPossible(il.labelstring());
 
        Counters & cnts = bp.documentClass().counters();
+
+       // Special case for `subequations' module.
+       if (il.latextype() == InsetLaTeXType::ENVIRONMENT &&
+           il.latexname() == "subequations") {
+               docstring equation(from_ascii("equation"));
+               docstring parentequation(from_ascii("parentequation"));
+               if (!deleted)
+                       cnts.step(equation, utype);
+               // save a copy of the equation counter definition
+               cnts.copy(equation, parentequation);
+               // redefine the equation counter definition
+               docstring const eqlabel = deleted ? from_ascii("#")
+                       : cnts.theCounter(equation, it->getParLanguage(bp)->code());
+               cnts.newCounter(equation, parentequation,
+                               eqlabel + from_ascii("\\alph{equation}"),
+                               eqlabel + from_ascii("\\alph{equation}"),
+                               cnts.guiName(parentequation));
+               InsetCollapsible::updateBuffer(it, utype, deleted);
+               // reset equation counter as it was.
+               cnts.copy(parentequation, equation);
+               cnts.remove(parentequation);
+               return;
+       }
+
        docstring const & count = il.counter();
        bool const have_counter = cnts.hasCounter(count);
        if (have_counter) {
-               Paragraph const & par = it.paragraph();
-               if (!par.isDeleted(it.pos())) {
+               if (!deleted) {
                        cnts.step(count, utype);
                        custom_label += ' ' +
                                cnts.theCounter(count, it.paragraph().getParLanguage(bp)->code());