]> git.lyx.org Git - lyx.git/blobdiff - src/undo.C
Partial fix bug 2092: branches not propagated to child documents
[lyx.git] / src / undo.C
index 1a854a192c23af5f132b204203b62139aeebb4b6..d5d34c0c4a6fbf1c63986375a4f42e82b4abcd41 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
@@ -93,10 +101,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);
        }