X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fundo.C;h=33b97827325f006009e10dbcc3ef59165aa0c583;hb=52eb91c94fb70d58dceef430659c8781de2eccda;hp=cecca1c39ec84526172f68de671477c022133889;hpb=1a9992c7967460eda189e5eab811e5a0e47f838f;p=lyx.git diff --git a/src/undo.C b/src/undo.C index cecca1c39e..33b9782732 100644 --- a/src/undo.C +++ b/src/undo.C @@ -17,18 +17,21 @@ #include "undo.h" #include "buffer.h" +#include "buffer_funcs.h" #include "cursor.h" #include "debug.h" #include "BufferView.h" #include "lyxtext.h" #include "paragraph.h" +#include "ParagraphList.h" -#include "mathed/math_support.h" -#include "insets/updatableinset.h" +#include "mathed/MathSupport.h" +#include "insets/inset.h" #include -using lyx::pit_type; + +namespace lyx { using std::advance; using std::endl; @@ -48,6 +51,14 @@ std::ostream & operator<<(std::ostream & os, Undo const & undo) } +bool samePar(StableDocIterator const & i1, StableDocIterator const & i2) +{ + StableDocIterator tmpi2 = i2; + tmpi2.pos() = i1.pos(); + return i1 == tmpi2; +} + + void doRecordUndo(Undo::undo_kind kind, DocIterator const & cell, pit_type first_pit, pit_type last_pit, @@ -77,10 +88,10 @@ void doRecordUndo(Undo::undo_kind kind, if (!undo_finished && kind != Undo::ATOMIC && !stack.empty() - && stack.top().cell == undo.cell - && stack.top().kind == undo.kind - && stack.top().from == undo.from - && stack.top().end == undo.end) + && samePar(stack.top().cell, undo.cell) + && stack.top().kind == undo.kind + && stack.top().from == undo.from + && stack.top().end == undo.end) return; // fill in the real data to be saved @@ -93,10 +104,10 @@ void doRecordUndo(Undo::undo_kind kind, // record the relevant paragraphs LyXText const * text = cell.text(); BOOST_ASSERT(text); - ParagraphList & plist = text->paragraphs(); - ParagraphList::iterator first = plist.begin(); + ParagraphList const & plist = text->paragraphs(); + ParagraphList::const_iterator first = plist.begin(); advance(first, first_pit); - ParagraphList::iterator last = plist.begin(); + ParagraphList::const_iterator last = plist.begin(); advance(last, last_pit + 1); undo.pars = ParagraphList(first, last); } @@ -159,6 +170,7 @@ bool textUndoOrRedo(BufferView & bv, // We stored the full cell here as there is not much to be // gained by storing just 'a few' paragraphs (most if not // all math inset cells have just one paragraph!) + // lyxerr << "undo.array=" << to_ascii(undo.array) <(*pit).setInsetOwner( - dynamic_cast(&dit.inset())); + pit->setInsetOwner(dit.realInset()); plist.insert(first, undo.pars.begin(), undo.pars.end()); + updateLabels(*buf); } // Set cursor @@ -243,7 +255,9 @@ void recordUndoInset(LCursor & cur, Undo::undo_kind kind) { LCursor c = cur; c.pop(); - recordUndo(c, kind); + Buffer * buf = cur.bv().buffer(); + doRecordUndo(kind, c, c.pit(), c.pit(), cur, + buf->params(), false, buf->undostack()); } @@ -280,3 +294,6 @@ void recordUndoFullDocument(BufferView * bv) ); undo_finished = false; } + + +} // namespace lyx