]> git.lyx.org Git - lyx.git/blobdiff - src/undo_funcs.C
Alfredo's second patch
[lyx.git] / src / undo_funcs.C
index 7055d6de65ffce229644554d39da5fd01d078ada..d0d9571881421bea5fd5dc07114d3b7cf39ab366 100644 (file)
@@ -321,11 +321,18 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
        }
 
        // create a new Undo
-       Paragraph * undopar = 0; // nothing to replace yet (undo of delete maybe)
+       Paragraph * undopar = 0; // nothing to replace (undo of delete maybe)
 
        Paragraph * start = first;
-       Paragraph * end = &*boost::prior(itbehind);
+       Paragraph * end = 0;
 
+       if (behind)
+               end = const_cast<Paragraph*>(behind->previous());
+       else {
+               end = start;
+               while (end->next())
+                       end = end->next();
+       }
        if (start && end && (start != end->next()) &&
            ((before_number != behind_number) ||
                 ((before_number < 0) && (behind_number < 0))))
@@ -466,6 +473,6 @@ void setRedo(BufferView * bv, Undo::undo_kind kind,
 
 void setCursorParUndo(BufferView * bv)
 {
-       setUndo(bv, Undo::FINISH, &*bv->text->cursor.par(),
-               bv->text->cursor.par()->next());
+       setUndo(bv, Undo::FINISH, bv->text->cursor.par(),
+               boost::next(bv->text->cursor.par()));
 }