- InsetList::const_iterator it = par.insetlist.begin();
- InsetList::const_iterator end = par.insetlist.end();
- for (; it != end ; ++it) {
- if (it->inset->lyxCode() == Inset::OPTARG_CODE)
- ++num;
+ // next, accept imaginary end-of-par characters
+ for (pit_type pit = 0; pit < pars_size; ++pit) {
+ pos_type pos = pars[pit].size();
+
+ if (pars[pit].isInserted(pos)) {
+ pars[pit].setChange(pos, Change(Change::UNCHANGED));
+ } else if (pars[pit].isDeleted(pos)) {
+ if (pit == pars_size - 1) {
+ // we cannot remove a par break at the end of the last
+ // paragraph; instead, we mark it unchanged
+ pars[pit].setChange(pos, Change(Change::UNCHANGED));
+ } else {
+ mergeParagraph(bparams, pars, pit);
+ --pit;
+ --pars_size;
+ }
+ }