- // clear end/begin fragments of the first/last par in selection
- bool all_erased = true;
-
- pars[startpit].erase(startpos, pars[startpit].size());
- if (pars[startpit].size() != startpos)
- all_erased = false;
-
- endpos -= pars[endpit].erase(0, endpos);
- if (endpos != 0)
- all_erased = false;
-
- // Loop through the deleted pars if any, erasing as needed
- for (pit_type pit = startpit + 1; pit != endpit;) {
- // "erase" the contents of the par
- pars[pit].erase(0, pars[pit].size());
- if (!pars[pit].size()) {
- // remove the par if it's now empty
- pars.erase(pars.begin() + pit);
+ // A paragraph break has to be physically removed by merging, but
+ // only if either (1) change tracking is off, or (2) the para break
+ // is "blue"
+ for (pit_type pit = startpit; pit != endpit + 1;) {
+ // FIXME: Change tracking (MG)
+ bool const merge = !params.trackChanges ||
+ pars[pit].isInserted(pars[pit].size());
+ pos_type const left = ( pit == startpit ? startpos : 0 );
+ pos_type const right = ( pit == endpit ? endpos :
+ pars[pit].size() + 1 );
+ // Logical erase only:
+ pars[pit].eraseChars(left, right, false);
+ // Separate handling of para break:
+ if (merge && pit != endpit &&
+ (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
+ pos_type const thissize = pars[pit].size();
+ if (doclear)
+ pars[pit + 1].stripLeadingSpaces();
+ mergeParagraph(params, pars, pit);