- // ok, now copy the paragraph
- for (pos_type i = 0, j = 0; i <= pos_end; ++i)
- if (moveItem(next, par, bparams, i, pos_insert + j))
+ // the imaginary end-of-paragraph character (at par.size()) has to be
+ // marked as unmodified. Otherwise, its change is adopted by the first
+ // character of the next paragraph.
+ if (par.lookupChange(par.size()).type != Change::UNCHANGED) {
+ lyxerr[Debug::CHANGES] <<
+ "merging par with inserted/deleted end-of-par character" << endl;
+ par.setChange(par.size(), Change(Change::UNCHANGED));
+ }
+
+ Change change = next.lookupChange(next.size());
+
+ // move the content of the second paragraph to the end of the first one
+ for (pos_type i = 0, j = pos_insert; i <= pos_end; ++i) {
+ if (moveItem(next, 0, par, j, bparams)) {