]> git.lyx.org Git - lyx.git/blobdiff - src/undo.C
code cosmetics to the iterator fix
[lyx.git] / src / undo.C
index 075697facf327a269aa10b19d4b71dc12c50558e..8e5fcc334f9acb23e249bba86f12a1268faf09db 100644 (file)
@@ -48,6 +48,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 +85,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
@@ -179,10 +187,10 @@ bool textUndoOrRedo(BufferView & bv,
 
                // this ugly stuff is needed until we get rid of the
                // inset_owner backpointer
-               ParagraphList::const_iterator pit = undo.pars.begin();
-               ParagraphList::const_iterator end = undo.pars.end();
+               ParagraphList::iterator pit = undo.pars.begin();
+               ParagraphList::iterator const end = undo.pars.end();
                for (; pit != end; ++pit)
-                       const_cast<Paragraph &>(*pit).setInsetOwner(&dit.inset());
+                       pit->setInsetOwner(dit.realInset());
                plist.insert(first, undo.pars.begin(), undo.pars.end());
        }