- // set the end for redoing later
- *endpar = (*par)->next()->next();
-
- // paste it!
- lastbuffer->next((*par)->next());
- (*par)->next()->previous(&*lastbuffer);
-
- (*par)->next(&*paragraphs.begin());
- paragraphs.begin()->previous(*par);
-
- if ((*par)->next() == lastbuffer)
- lastbuffer = *par;
-
- mergeParagraph(current_view->buffer()->params,
- current_view->buffer()->paragraphs, *par);
- // store the new cursor position
- *par = &*lastbuffer;
- pos = lastbuffer->size();
- // maybe some pasting
- if (lastbuffer->next() && paste_the_end) {
- if (lastbuffer->next()->hasSameLayout(*lastbuffer)) {
- mergeParagraph(current_view->buffer()->params,
- current_view->buffer()->paragraphs, lastbuffer);
- } else if (!lastbuffer->next()->size()) {
- lastbuffer->next()->makeSameLayout(*lastbuffer);
- mergeParagraph(current_view->buffer()->params, current_view->buffer()->paragraphs, lastbuffer);
- } else if (!lastbuffer->size()) {
- lastbuffer->makeSameLayout(*lastbuffer->next());
- mergeParagraph(current_view->buffer()->params,
- current_view->buffer()->paragraphs, lastbuffer);
+
+ // Set the end for redoing later.
+ ParagraphList::iterator endpit = boost::next(boost::next(pit));
+
+ // Paste it!
+
+ ParagraphList::iterator past_pit = boost::next(pit);
+ pars.splice(past_pit, simple_cut_clone);
+ ParagraphList::iterator last_paste = boost::prior(past_pit);
+
+ // If we only inserted one paragraph.
+ if (boost::next(pit) == last_paste)
+ last_paste = pit;
+
+ mergeParagraph(buffer.params, pars, pit);
+
+ // Store the new cursor position.
+ pit = last_paste;
+ pos = last_paste->size();
+
+ // Maybe some pasting.
+#warning CHECK! Are we comparing last_paste to the wrong list here? (Lgb)
+ if (boost::next(last_paste) != pars.end() &&
+ paste_the_end) {
+ if (boost::next(last_paste)->hasSameLayout(*last_paste)) {
+ mergeParagraph(buffer.params, pars,
+ last_paste);
+ } else if (boost::next(last_paste)->empty()) {
+ boost::next(last_paste)->makeSameLayout(*last_paste);
+ mergeParagraph(buffer.params, pars,
+ last_paste);
+ } else if (last_paste->empty()) {
+ last_paste->makeSameLayout(*boost::next(last_paste));
+ mergeParagraph(buffer.params, pars,
+ last_paste);