// 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
+ if (! buf->undostack().empty()
+ && buf->undostack().top().kind == kind
&& buf->undostack().top().first_par_offset == first_offset
&& buf->undostack().top().last_par_offset == last_offset) {
// No additonal undo recording needed -
}
// Record the cursor position in a stable way.
- int const cursor_offset = std::distance
- (text->ownerParagraphs().begin(), text->cursor.par());
+ int const cursor_offset = text->cursor.par();
// Make and push the Undo entry
stack.push(Undo(kind, inset_id,
advance(last, plist.size() - undo.last_par_offset);
plist.erase(first, ++last);
}
-
+
// Re-insert old stuff instead
{
if (plist.empty()) {
buf->getInsetFromID(undo.inset_id));
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
- ParagraphList::iterator cursor = text->ownerParagraphs().begin();
- advance(cursor, undo.cursor_par_offset);
- text->setCursorIntern(cursor, undo.cursor_pos);
+ text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
if (inset) {
// Magic needed to update inset internal state
}
// set cursor again to force the position to be the right one
- text->setCursorIntern(cursor, undo.cursor_pos);
+ text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
// Clear any selection and set the selection
// cursor for any new selection.
void recordUndo(BufferView * bv, Undo::undo_kind kind)
{
- recordUndo(bv, kind, bv->text->cursor.par());
+ recordUndo(bv, kind, bv->text->cursorPar());
}