- // What happens is the following. Later on, moveItem() will copy
- // over characters from the next paragraph to be inserted into this
- // position. Now, if the first char to be so copied is "red" (i.e.,
- // marked deleted) and the paragraph break is marked "blue",
- // insertChar will trigger (eventually, through record(), and see
- // del() and erase() in changes.C) a "hard" character deletion.
- // Which doesn't make sense of course at this pos, but the effect is
- // to shorten the change range to which this para break belongs, by
- // one. It will (should) remain "orphaned", having no CT info to it,
- // and check() in changes.C will assert. Setting the para break
- // forcibly to "black" prevents this scenario. -- MV 13.3.2006
- par.setChange(par.size(), Change::UNCHANGED);
-
- Change::Type cr = next.lookupChange(next.size());
- // ok, now copy the paragraph
- for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
- Change::Type change = next.lookupChange(i);
- if (moveItem(next, par, bparams, i, pos_insert + j, change))
+ // 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)) {