]> git.lyx.org Git - lyx.git/blobdiff - src/undo_funcs.C
op-1-a.diff
[lyx.git] / src / undo_funcs.C
index 8d15fed249e471e83c8f8e7406f3aefab029e192..6235df6fa9b6c19f88ebc0bbbfccada51a167bff 100644 (file)
@@ -14,6 +14,7 @@
 #include "BufferView.h"
 #include "buffer.h"
 #include "insets/updatableinset.h"
+#include "insets/insettext.h"
 #include "debug.h"
 #include "support/LAssert.h"
 
@@ -166,17 +167,28 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                undopar->previous(before);
                if (before)
                        before->next(undopar);
-               else
-                       bv->text->ownerParagraph(firstUndoParagraph(bv, undo.number_of_inset_id)->id(),
-                                                undopar);
-
+               else {
+                       int id = firstUndoParagraph(bv, undo.number_of_inset_id)->id();
+                       Paragraph * op = bv->buffer()->getParFromID(id);
+                       if (op && op->inInset()) {
+                               static_cast<InsetText*>(op->inInset())->paragraph(undopar);
+                       } else {
+                               bv->buffer()->paragraphs.set(undopar);
+                       }
+               }
        } else {
                // We enter here on DELETE undo operations where we have to
                // substitue the second paragraph with the first if the removed
                // one is the first!
                if (!before && behind) {
-                       bv->text->ownerParagraph(firstUndoParagraph(bv, undo.number_of_inset_id)->id(),
-                                                behind);
+                       int id = firstUndoParagraph(bv, undo.number_of_inset_id)->id();
+                       Paragraph * op = bv->buffer()->getParFromID(id);
+                       if (op && op->inInset()) {
+                               static_cast<InsetText*>(op->inInset())->paragraph(behind);
+                       } else {
+                               bv->buffer()->paragraphs.set(behind);
+                       }
+
                        undopar = behind;
                }
        }
@@ -486,6 +498,6 @@ void setRedo(BufferView * bv, Undo::undo_kind kind,
 
 void setCursorParUndo(BufferView * bv)
 {
-       setUndo(bv, Undo::FINISH, bv->text->cursor.par(),
+       setUndo(bv, Undo::FINISH, &*bv->text->cursor.par(),
                bv->text->cursor.par()->next());
 }