On Sun, Jan 01, 2006 at 03:40:34PM +0100, Michael Gerz wrote: > Martin Vermeer wrote: > > >The code is here (text.C): > > > > 1026 void LyXText::breakParagraph(LCursor & cur, bool keep_layout) > > 1027 { > > 1028 BOOST_ASSERT(this == cur.text()); > > 1029 // allow only if at start or end, or all previous is new > > text > > 1030 Paragraph & cpar = cur.paragraph(); > > 1031 pit_type cpit = cur.pit(); > > 1032 > > 1033 if (cur.pos() != 0 && cur.pos() != cur.lastpos() > > 1034 && cpar.isChangeEdited(0, cur.pos())) > > 1035 return; > > > >Nothing about the 'why' though... > > > >- Martin > > > > > Hopefully this restriction is no longer necessary. It would be nice to > see when this code has been introduced. (maybe some historic legacy?). > > We can expect people (like me :-)) to look for alternative ways to > introduce line/par breaks (see my previous mail) but the consequence > should be the same as if the line/par break was entered directly.
My understanding is this (but John Levon should know, he did this initially): the change tracking system builds up a table of ranges that are being change tracked. They can be in one of three states: UNCHANGED, INSERTED (blue) and DELETED (red overline). A range can be a single character or a range of characters within a paragraph, i.e., can currently not contain a newline. To sort-of fix this deficiency, there appears to be the implied _convention_: if a paragraph contains _only_ added characters, and no "originally present" or deleted characters -- as tested by !isChangeEdited -- then the newline following it is of the INSERTED type. Otherwise it is of the UNCHANGED type. The break-out conditions found in the breakParagraph and backspace methods sort-of enforce this, by not allowing you to create new paragraphs unless they will contain only newly inserted characters. Then, the whole paragraph, including its terminating newline, will disappear when you roll back your changes. Any paragraph containing also "original" characters will remain in the doc, with its terminal newline. If inserting newlines directly _were_ allowed, they would not be rolled back together with the tracked changes to the surrounding characters. In that sense change tracking would be inconsistent. Cutting and pasting selections subvert this scheme. I hope this explanation is both clear and correct ;-) - Martin
pgpbZdOx8BZ9p.pgp
Description: PGP signature