- // paste it!
- lastbuffer->next(pit->next());
- pit->next()->previous(&*lastbuffer);
-
- pit->next(&*paragraphs.begin());
- paragraphs.begin()->previous(&*pit);
-
- if (boost::next(pit) == lastbuffer)
- lastbuffer = pit;
-
- mergeParagraph(current_view->buffer()->params, pars, pit);
- // store the new cursor position
- pit = lastbuffer;
- pos = lastbuffer->size();
- // maybe some pasting
- if (boost::next(lastbuffer) != paragraphs.end() && paste_the_end) {
- if (boost::next(lastbuffer)->hasSameLayout(*lastbuffer)) {
- mergeParagraph(current_view->buffer()->params, pars,
- lastbuffer);
- } else if (!boost::next(lastbuffer)->size()) {
- boost::next(lastbuffer)->makeSameLayout(*lastbuffer);
- mergeParagraph(current_view->buffer()->params, pars,
- lastbuffer);
- } else if (!lastbuffer->size()) {
- lastbuffer->makeSameLayout(*boost::next(lastbuffer));
- mergeParagraph(current_view->buffer()->params, pars,
- lastbuffer);
+ // 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);