-
- startpar->breakParagraphConservative(current_view->buffer()->params,
- start);
-
- // store the selection
- if (realcut) {
- buf = startpar->next();
- buf->previous(0);
- } else {
- startpar->next()->previous(0);
- }
- (*endpar)->previous()->next(0);
-
- // cut the selection
- startpar->next(*endpar);
-
- (*endpar)->previous(startpar);
-
- // the cut selection should begin with standard layout
- if (realcut)
- buf->clear();
-
- // paste the paragraphs again, if possible
- if (doclear)
- startpar->next()->stripLeadingSpaces(textclass);
- if (startpar->hasSameLayout(startpar->next()) ||
- !startpar->next()->size()) {
- startpar->pasteParagraph(current_view->buffer()->params);
- (*endpar) = startpar; // this because endpar gets deleted here!
- }
- // this paragraph's are of noone's owner!
- Paragraph * p = buf;
- while (p) {
- p->setInsetOwner(0);
- p = p->next();
+ }
+
+ // Loop through the deleted pars if any, erasing as needed
+
+ Paragraph * pit = startpar->next();
+
+ while (1) {
+ // *endpar can be 0
+ if (!pit)
+ break;
+
+ Paragraph * next = pit->next();
+
+ // "erase" the contents of the par
+ if (pit != *endpar) {
+ actually_erased |= pit->erase(0, pit->size());
+
+ // remove the par if it's now empty
+ if (actually_erased) {
+ pit->previous()->next(pit->next());
+ if (next) {
+ next->previous(pit->previous());
+ }
+ lyxerr << "deleting pit " << pit << endl;
+
+ delete pit;
+ }