]> git.lyx.org Git - lyx.git/blobdiff - src/undo.C
the spellcheck cleanup
[lyx.git] / src / undo.C
index bd2d6d0181cd17ba3b788f3bbf38acdcc28de659..e62cb065246e5c4608454673d54035bd089c7505 100644 (file)
@@ -23,6 +23,8 @@
 #include "lyxtext.h"
 #include "paragraph.h"
 
+#include "insets/updatableinset.h" // for dynamic_cast<UpdatableInset *>
+
 using lyx::paroffset_type;
 
 
@@ -87,7 +89,7 @@ ParIterator num2pit(BufferView * bv, int num)
 
        for ( ; num && pit != end; ++pit, --num)
                ;
-       
+
        if (pit != end)
                return pit;
 
@@ -145,12 +147,9 @@ void recordUndo(Undo::undo_kind kind,
        ParagraphList::iterator last = plist.begin();
        advance(last, last_par);
 
-       for (ParagraphList::iterator it = first; it != last; ++it) {
+       for (ParagraphList::iterator it = first; it != last; ++it)
                undo_pars.push_back(*it);
-               undo_pars.back().id(it->id());
-       }
        undo_pars.push_back(*last);
-       undo_pars.back().id(last->id());
 
        // and make sure that next time, we should be combining if possible
        undo_finished = false;
@@ -185,26 +184,26 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
 
        // set cursor
        lyxerr <<   "undo, text: " << undo.text
-               << " inset: " << pit.inset()
-               << " index: " << undo.index
-               << std::endl;
-       InsetOld * inset = pit.inset();
-       if (inset) {
-               // magic needed to cope with inset locking
-               inset->edit(bv, undo.index);
-       }
+              << " inset: " << pit.inset()
+              << " index: " << undo.index
+              << " par: " << undo.cursor_par
+              << " pos: " << undo.cursor_pos
+              << std::endl;
 
        // set cursor again to force the position to be the right one
-       text->setCursorIntern(undo.cursor_par, undo.cursor_pos);
+       text->cursor.par(undo.cursor_par);
+       text->cursor.pos(undo.cursor_pos);
 
        // clear any selection
        text->clearSelection();
        text->selection.cursor = text->cursor;
        text->updateCounters();
 
-       // rebreak the entire document
+       // rebreak the entire lyxtext
        bv->text->fullRebreak();
 
+       pit.lockPath(bv);
+       
        finishUndo();
        return true;
 }