X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fundo.C;h=b60d0e11b95f8c3d3fddbbd00d643ad1c4d003c7;hb=2734cc154853c61a7ea54bfeea3adc908f68bdc5;hp=075697facf327a269aa10b19d4b71dc12c50558e;hpb=af5acb6dc7e2f77a1f7a69d4f1bbfa25c7b50ea3;p=lyx.git diff --git a/src/undo.C b/src/undo.C index 075697facf..b60d0e11b9 100644 --- a/src/undo.C +++ b/src/undo.C @@ -22,13 +22,15 @@ #include "BufferView.h" #include "lyxtext.h" #include "paragraph.h" +#include "ParagraphList.h" -#include "mathed/math_support.h" +#include "mathed/MathSupport.h" #include "insets/inset.h" #include -using lyx::pit_type; + +namespace lyx { using std::advance; using std::endl; @@ -48,6 +50,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 +87,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 @@ -159,6 +169,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=" << undo.array <(*pit).setInsetOwner(&dit.inset()); + pit->setInsetOwner(dit.realInset()); plist.insert(first, undo.pars.begin(), undo.pars.end()); } @@ -242,7 +253,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()); } @@ -279,3 +292,6 @@ void recordUndoFullDocument(BufferView * bv) ); undo_finished = false; } + + +} // namespace lyx