diff --git a/src/ChangeLog b/src/ChangeLog index b40100846c..cd2d312313 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2006-03-15 Martin Vermeer + + * CutAndPaste.C (pasteSelectionHelper): comments + * paragraph_funcs.C (mergeParagraph): fix Juergen's cut&paste bug + * changes.h: comments + * paragraph.C (stripLeadingSpaces): remove unnecessary setChange + * text.C (backspace): allow deletion of inserted para break + Change tracking -related bug fixes (reported by Juergen) and + some documentation work + 2006-03-15 Jean-Marc Lasgouttes * MenuBackend.C (expand): make sure the menu is empty before diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 4dcf4f1806..9c78a841ed 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -234,7 +234,8 @@ pasteSelectionHelper(Buffer const & buffer, pit = last_paste; pos = pars[last_paste].size(); - // Maybe some pasting. + // Join (conditionally) last pasted paragraph with next one, i.e., + // the tail of the spliced document paragraph if (!empty && last_paste + 1 != pit_type(pars.size())) { if (pars[last_paste + 1].hasSameLayout(pars[last_paste])) { mergeParagraph(buffer.params(), pars, last_paste); diff --git a/src/changes.h b/src/changes.h index 1103bd2012..1777c8f09a 100644 --- a/src/changes.h +++ b/src/changes.h @@ -84,7 +84,8 @@ public: /// return true if there is a deleted or unchanged range contained bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const; - /// remove the given entry + /// remove the given entry. This implies that a character was + /// deleted at pos, and will adjust all range bounds past it void erase(lyx::pos_type pos); /// output latex to mark a transition between two changetypes @@ -134,22 +135,23 @@ private: typedef std::vector ChangeTable; - /// our table of changes + /// our table of changes, every row a range and change descriptor ChangeTable table_; /// change type for an empty paragraph Change::Type empty_type_; - /// handle a delete + /// handle a delete, either logical or physical (see erase) void del(Change change, ChangeTable::size_type pos); - /// handle an add + /// handle an add, adjusting range bounds past it void add(Change change, ChangeTable::size_type pos); - /// merge neighbouring ranges + /// merge neighbouring ranges, assuming that they are abutting + /// (as done by set()) void merge(); - /// consistency check + /// consistency check, needed before merge() void check() const; }; diff --git a/src/paragraph.C b/src/paragraph.C index 2cbbf6180b..6060876d9f 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -564,8 +564,6 @@ int Paragraph::stripLeadingSpaces() int i = 0; while (!empty() && (isNewline(0) || isLineSeparator(0))) { - // Set Change::Type to Change::INSERTED to quietly remove it - setChange(0, Change::INSERTED); erase(0); ++i; } diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index ff134379b2..b5b43d87d7 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -236,6 +236,19 @@ void mergeParagraph(BufferParams const & bparams, pos_type pos_end = next.size() - 1; pos_type pos_insert = par.size(); + // 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) { diff --git a/src/text.C b/src/text.C index d3f8b3b2e1..a0f31e80fb 100644 --- a/src/text.C +++ b/src/text.C @@ -1681,9 +1681,12 @@ bool LyXText::backspace(LCursor & cur) // Previous paragraph, mark "carriage return" as // deleted: Paragraph & par = pars_[cur.pit() - 1]; - par.setChange(par.size(), Change::DELETED); - setCursorIntern(cur, cur.pit() - 1, par.size()); - return false; + // Take care of a just inserted para break: + if (par.lookupChange(par.size()) != Change::INSERTED) { + par.setChange(par.size(), Change::DELETED); + setCursorIntern(cur, cur.pit() - 1, par.size()); + return false; + } } needsUpdate = backspacePos0(cur);