]> git.lyx.org Git - features.git/commitdiff
Fix undo bugs.
authorJürgen Vigna <jug@sad.it>
Mon, 14 Oct 2002 14:59:50 +0000 (14:59 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 14 Oct 2002 14:59:50 +0000 (14:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5395 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insettext.C
src/undo_funcs.C

index 79cde1132069b26bbf6077ee663e693f66a349f6..d1bdbbcf8e29f71042d4ff86a315e434420d19c8 100644 (file)
@@ -1,3 +1,11 @@
+2002-10-14  Juergen Vigna  <jug@sad.it>
+
+       * undo_funcs.C (textHandleUndo): alter the order in which the
+       new undopar is added to the LyXText, as we have to set first
+       the right prev/next and then add it as otherwise the rebuild of
+       LyXText is not correct. Also reset the cursor to the right paragraph,
+       with this IMO we could remove the hack in "redoParagraphs()".
+
 2002-10-09  Angus Leeming  <leeming@lyx.org>
 
        * Bufferview_pimpl.C (dispatch): call InsetCitation::setLoadingBuffer
index 66e58074912309d2ee97186c042a329a5b771a9f..5d4d9da093b49adadbb5d91ae4030a0c7da9e70d 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-14  Juergen Vigna  <jug@sad.it>
+
+       * insettext.C (localDispatch): remove double setUndo in Cut/Delete/
+       Backspace functions which confused the Undo handling.
+
 2002-10-09  Angus Leeming  <leeming@lyx.org>
 
        * insetcite.[Ch] (setLoadingBuffer): new method, invoked by
index d69f823f98f23c8e3329e90970515c95e5ce48fa..4e76daac6748545826923a49d9e35af4b59c3626 100644 (file)
@@ -1266,9 +1266,11 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
                         * typed in now. Depends on lyxrc settings
                         * "auto_region_delete", which defaults to
                         * true (on). */
-
+#if 0
+                       // This should not be needed here and is also WRONG!
                        setUndo(bv, Undo::INSERT,
                                lt->cursor.par(), lt->cursor.par()->next());
+#endif
                        bv->switchKeyMap();
                        if (lyxrc.auto_region_delete) {
                                if (lt->selection.set()) {
@@ -1359,8 +1361,6 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
                updwhat = CURSOR;
                break;
        case LFUN_BACKSPACE: {
-               setUndo(bv, Undo::DELETE,
-                       lt->cursor.par(), lt->cursor.par()->next());
                if (lt->selection.set())
                        lt->cutSelection(bv, true, false);
                else
@@ -1371,8 +1371,6 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
        break;
 
        case LFUN_DELETE: {
-               setUndo(bv, Undo::DELETE,
-                       lt->cursor.par(), lt->cursor.par()->next());
                if (lt->selection.set()) {
                        lt->cutSelection(bv, true, false);
                } else {
@@ -1384,8 +1382,6 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
        break;
 
        case LFUN_CUT: {
-               setUndo(bv, Undo::DELETE,
-                       lt->cursor.par(), lt->cursor.par()->next());
                lt->cutSelection(bv);
                updwhat = CURSOR_PAR;
                updflag = true;
@@ -1425,8 +1421,11 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
                                break;
                        }
                }
+#if 0
+               // This should not be needed here and is also WRONG!
                setUndo(bv, Undo::INSERT,
                        lt->cursor.par(), lt->cursor.par()->next());
+#endif
                lt->pasteSelection(bv);
                // bug 393
                lt->clearSelection();
@@ -1459,8 +1458,11 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
                        result = DISPATCHED;
                        break;
                }
+#if 0
+               // This should not be needed here and is also WRONG!
                setUndo(bv, Undo::INSERT,
                        lt->cursor.par(), lt->cursor.par()->next());
+#endif
                lt->insertChar(bv, Paragraph::META_NEWLINE);
                updwhat = CURSOR | CURSOR_PAR;
                updflag = true;
index e72a5c1d95588df968b0203f0f246eb1ec260235..2d8e529b2984f91bb037c4171b11ec75687287e3 100644 (file)
@@ -154,15 +154,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,21 +185,20 @@ 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);
+       } 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);
        }
 
        Paragraph * endpar = 0;