- int const end_par = text->ownerParagraphs().size() - last_par;
-
- // Undo::ATOMIC are always recorded (no overlapping there).
- // overlapping only with insert and delete inside one paragraph:
- // nobody wants all removed character appear one by one when undoing.
- if (!undo_finished && kind != Undo::ATOMIC) {
- // Check whether storing is needed.
- if (!buf->undostack().empty()
- && buf->undostack().top().kind == kind
- && buf->undostack().top().first_par == first_par
- && buf->undostack().top().end_par == end_par) {
- // No additonal undo recording needed -
- // effectively, we combine undo recordings to one.
- return;
- }
- }
-
- // make and push the Undo entry
- int textnum;
- ParIterator pit = text2pit(text, textnum);
- stack.push(Undo(kind, textnum, pit.index(),
- first_par, end_par, text->cursor.par(), text->cursor.pos()));
- lyxerr << "undo record: " << stack.top() << std::endl;
-
- // record the relevant paragraphs
- ParagraphList & undo_pars = stack.top().pars;
-
- ParagraphList & plist = text->ownerParagraphs();
- ParagraphList::iterator first = plist.begin();
- advance(first, first_par);
- ParagraphList::iterator last = plist.begin();
- advance(last, last_par);
-
- for (ParagraphList::iterator it = first; it != last; ++it)
- undo_pars.push_back(*it);
- undo_pars.push_back(*last);
-
- // and make sure that next time, we should be combining if possible
- undo_finished = false;