X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText2.cpp;h=cc5340317a0956e688fa87537b6fdb2ec6941003;hb=e4b80698be91708ce1b9fd86d6032245ef4f3dc7;hp=4959a3fc814d259b34366b3e0854e31c1ba3f27f;hpb=939d25561d5345d367309b7994eaefa355072456;p=lyx.git diff --git a/src/Text2.cpp b/src/Text2.cpp index 4959a3fc81..cc5340317a 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -933,6 +933,15 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur, void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges) +{ + pos_type last_pos = static_cast(pars_[last].size() - 1); + deleteEmptyParagraphMechanism(first, last, 0, last_pos, trackChanges); +} + + +void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, + pos_type first_pos, pos_type last_pos, + bool trackChanges) { LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), return); @@ -943,8 +952,9 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool tra * (1) Delete consecutive spaces */ if (!par.isFreeSpacing()) { - pos_type from = 0; - while (from < par.size()) { + pos_type from = (pit == first) ? first_pos : 0; + pos_type to_pos = (pit == last) ? last_pos + 1 : par.size(); + while (from < to_pos) { // skip non-spaces while (from < par.size() && (!par.isLineSeparator(from) || par.isDeleted(from)))