Without much hope nor desire that it will be considered, please find attached a patch that represent my current version of this file. Some of it might help.

Abdel.
Index: buffer_funcs.C
===================================================================
--- buffer_funcs.C      (revision 13538)
+++ buffer_funcs.C      (working copy)
@@ -329,20 +329,21 @@
 }
 
 
-bool needEnumCounterReset(ParIterator const & it)
+bool needEnumCounterReset(size_t const pos, ParagraphList const & pars)
 {
-       Paragraph const & par = *it;
-       BOOST_ASSERT(par.layout()->labeltype == LABEL_ENUMERATE);
-       lyx::depth_type const cur_depth = par.getDepth();
-       ParIterator prev_it = it;
-       while (prev_it.pit()) {
-               --prev_it.top().pit();
-               Paragraph const & prev_par = *prev_it;
-               if (prev_par.getDepth() <= cur_depth)
-                       return  prev_par.layout()->labeltype != LABEL_ENUMERATE;
-       }
-       // start of nested inset: reset
-       return true;
+       if (pars[pos].layout()->labeltype != LABEL_ENUMERATE)
+               return false;
+
+    // start of nested inset: reset
+       if (pos == 0)
+           return true;
+
+    lyx::depth_type const cur_depth = pars[pos].getDepth();
+    for (size_t i = pos - 1; i != 0; --i) {
+        if (pars[i].getDepth() <= cur_depth)
+            return pars[i].layout()->labeltype != LABEL_ENUMERATE;
+    }
+       return false;
 }
 
 
@@ -379,6 +380,10 @@
                par.setLabelWidthString(string());
        }
 
+       // is it a layout that has no label at all (ex: standard layout)?
+       if (layout->labeltype == LABEL_NO_LABEL)
+               return;
+
        // is it a layout that has an automatic label?
        if (layout->labeltype == LABEL_COUNTER) {
                if (layout->toclevel <= buf.params().secnumdepth
@@ -435,7 +440,7 @@
                }
 
                // Maybe we have to reset the enumeration counter.
-               if (needEnumCounterReset(it))
+               if (needEnumCounterReset(it.pit(), buf.paragraphs()))
                        counters.reset(enumcounter);
 
                counters.step(enumcounter);
@@ -508,7 +513,9 @@
        // start over
        buf.params().getLyXTextClass().counters().reset();
 
-       for (ParIterator it = par_iterator_begin(buf.inset()); it; ++it) {
+       ParIterator end = par_iterator_end(buf.inset());
+
+       for (ParIterator it = par_iterator_begin(buf.inset()); it != end; ++it) 
{
                // reduce depth if necessary
                if (it.pit()) {
                        Paragraph const & prevpar = it.plist()[it.pit() - 1];

Reply via email to