]> git.lyx.org Git - lyx.git/blobdiff - src/undo_funcs.C
more code in the menu backend == less code in the menu frontends; add support for...
[lyx.git] / src / undo_funcs.C
index 41578aa46e5f0f12bbfae10c9f8469a64d125d1d..96d5497491b371cf036bd55a3747402be7032184 100644 (file)
@@ -9,10 +9,6 @@
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "undo_funcs.h"
 #include "lyxtext.h"
 #include "BufferView.h"
@@ -31,7 +27,7 @@ using boost::shared_ptr;
 
 /// the flag used by FinishUndo();
 bool undo_finished;
-/// FIXME
+/// whether actions are not added to the undo stacks
 bool undo_frozen;
 
 namespace {
@@ -154,15 +150,26 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                }
        }
 
+       // The order here is VERY IMPORTANT. We have to set the right
+       // next/prev pointer in the paragraphs so that a rebuild of
+       // the LyXText works!!!
+
+       // thread the end of the undo onto the par in front if any
+       if (lastundopar) {
+               lastundopar->next(behind);
+               if (behind)
+                       behind->previous(lastundopar);
+       }
+
        // put the new stuff in the list if there is one
        if (undopar) {
+               undopar->previous(before);
                if (before)
                        before->next(undopar);
                else
                        bv->text->ownerParagraph(firstUndoParagraph(bv, undo.number_of_inset_id)->id(),
                                                 undopar);
 
-               undopar->previous(before);
        } else {
                // We enter here on DELETE undo operations where we have to
                // substitue the second paragraph with the first if the removed
@@ -174,22 +181,26 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                }
        }
 
-       // thread the end of the undo onto the par in front if any
-       if (lastundopar) {
-               lastundopar->next(behind);
-               if (behind)
-                       behind->previous(lastundopar);
-       }
-
 
        // Set the cursor for redoing
-       if (before) {
+       if (before) { // if we have a par before the undopar
                Inset * it = before->inInset();
                if (it)
                        it->getLyXText(bv)->setCursorIntern(bv, before, 0);
                else
                        bv->text->setCursorIntern(bv, before, 0);
        }
+// we are not ready for this we cannot set the cursor for a paragraph
+// which is not already in a row of LyXText!!!
+#if 0
+       else { // otherwise this is the first one and we start here
+               Inset * it = undopar->inInset();
+               if (it)
+                       it->getLyXText(bv)->setCursorIntern(bv, undopar, 0);
+               else
+                       bv->text->setCursorIntern(bv, undopar, 0);
+       }
+#endif
 
        Paragraph * endpar = 0;
        // calculate the endpar for redoing the paragraphs.