]> git.lyx.org Git - lyx.git/blobdiff - src/buffer_funcs.C
fix crash when collapsing ert with cursor inside
[lyx.git] / src / buffer_funcs.C
index 057be070d7e6639f621d2e1b129f443c9631e365..61cf756fc43e1c5ac08cc01d409dd7b8096c19d7 100644 (file)
@@ -26,6 +26,7 @@
 #include "LaTeX.h"
 #include "lyxtextclass.h"
 #include "paragraph.h"
+#include "paragraph_funcs.h"
 #include "ParagraphList_fwd.h"
 #include "ParagraphParameters.h"
 #include "pariterator.h"
@@ -377,9 +378,14 @@ void setCounter(Buffer const & buf, ParIterator & it)
 
        // is it a layout that has an automatic label?
        if (layout->labeltype == LABEL_COUNTER) {
-               counters.step(layout->counter);
-               string label = expandLabel(textclass, layout, par.params().appendix());
-               par.params().labelString(label);
+               if (layout->toclevel <= buf.params().secnumdepth
+                   && (!layout->isEnvironment()
+                       || isFirstInSequence(it.pit(), it.plist()))) {
+                       counters.step(layout->counter);
+                       string label = expandLabel(textclass, layout,
+                                                  par.params().appendix());
+                       par.params().labelString(label);
+               }
        } else if (layout->labeltype == LABEL_ITEMIZE) {
                // At some point of time we should do something more
                // clever here, like:
@@ -434,10 +440,9 @@ void setCounter(Buffer const & buf, ParIterator & it)
        } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
                counters.step("bibitem");
                int number = counters.value("bibitem");
-               if (par.bibitem()) {
+               if (par.bibitem()) 
                        par.bibitem()->setCounter(number);
-                       par.params().labelString(layout->labelstring());
-               }
+               par.params().labelString(layout->labelstring());
                // In biblio should't be following counters but...
        } else if (layout->labeltype == LABEL_SENSITIVE) {
                // Search for the first float or wrap inset in the iterator
@@ -447,7 +452,7 @@ void setCounter(Buffer const & buf, ParIterator & it)
                        --i;
                        InsetBase * const in = &it[i].inset();
                        if (in->lyxCode() == InsetBase::FLOAT_CODE
-                           || in->lyxCode() == InsetBase::WRAP_CODE) 
+                           || in->lyxCode() == InsetBase::WRAP_CODE)
                                type = in->getInsetName();
                                break;
                }