Michael Gerz wrote: > Alfredo Braunstein schrieb: >> http://bugzilla.lyx.org/show_bug.cgi?id=3600 >> >> The problem is simply that stripLeadingSpaces is called on the last >> paragraph of the selection and the endpos position is not adjusted if the >> par shrinks. >> >> Can someone remind me why do we need to call stripLeadingSpaces? Is this >> something related to change tracking? >> > As stripLeadingSpace depends on "doClear", I can assure that it was not > driven by change tracking. (though it has to consider CT!) > > Some comments on your patch: > > Index: src/CutAndPaste.cpp > =================================================================== > --- src/CutAndPaste.cpp (revision 18938) > +++ src/CutAndPaste.cpp (working copy) > @@ -315,14 +309,17 @@ > > // Separate handling of paragraph break: > if (merge && pit != endpit && > - (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + > 1]))) { > - pos_type const thissize = pars[pit].size(); > + (pit + 1 != endpit || pars[pit].hasSameLayout(pars[endpit]))) > { > + int const nextsize = pars[pit + 1].size(); > > This looks suspicious (with and without your patch). Shouldn't the || in > fact be a && ?
No. It says that either it is one intermediate paragraph (so it has to be removed) or it is the paragraph before the final one, and in this case we merge only if they share the same layout. The whole loop is hidous ;-) > + if (pit == endpit) { > + endpos += pars[pit].size(); > + endpos -= nextsize - pars[endpit].size(); > + endpos = std::max(endpos, 0); > + } > > If pit == endpit, stripLeadingSpaces() is not invoked, right? It think > something is wrong here... Ah right, I moved the block the before the --endpit in a raptus of genius. Should probably be + if (pit + 1 == endpit) { I don't have time now, but I'll check this and post an updated patch ASAP. A/