X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FUndo.cpp;h=eec7ff446601aa8399956693e893aabe77c0fb61;hb=604a3341d9bd6b6bee6f042292f28b89027ca2b5;hp=388d009b56d3e6477c9b406226c09274033b4576;hpb=3aecc2c4fff1dc1408a34f61b6a6a7a028a55efc;p=lyx.git diff --git a/src/Undo.cpp b/src/Undo.cpp index 388d009b56..eec7ff4466 100644 --- a/src/Undo.cpp +++ b/src/Undo.cpp @@ -71,9 +71,9 @@ struct UndoElement StableDocIterator const & cel, pit_type fro, pit_type en, ParagraphList * pl, MathData * ar, BufferParams const & bp, - bool ifb, size_t gid) : + bool ifb, bool lc, size_t gid) : kind(kin), cursor(cur), cell(cel), from(fro), end(en), - pars(pl), array(ar), bparams(0), isFullBuffer(ifb), group_id(gid) + pars(pl), array(ar), bparams(0), isFullBuffer(ifb), lyx_clean(lc), group_id(gid) { if (isFullBuffer) bparams = new BufferParams(bp); @@ -91,6 +91,7 @@ struct UndoElement bparams = ue.isFullBuffer ? new BufferParams(*ue.bparams) : ue.bparams; isFullBuffer = ue.isFullBuffer; + lyx_clean = ue.lyx_clean; group_id = ue.group_id; } /// @@ -117,6 +118,8 @@ struct UndoElement BufferParams const * bparams; /// Only used in case of full backups bool isFullBuffer; + /// Was the buffer clean at this point? + bool lyx_clean; /// the element's group id size_t group_id; private: @@ -163,6 +166,12 @@ public: } } + /// Mark all the elements of the stack as dirty + void markDirty() { + for (size_t i = 0; i != c_.size(); ++i) + c_[i].lyx_clean = false; + } + private: /// Internal contents. std::deque c_; @@ -242,11 +251,11 @@ bool Undo::hasRedoStack() const } -static bool samePar(StableDocIterator const & i1, StableDocIterator const & i2) +void Undo::markDirty() { - StableDocIterator tmpi2 = i2; - tmpi2.pos() = i1.pos(); - return i1 == tmpi2; + d->undo_finished_ = true; + d->undostack_.markDirty(); + d->redostack_.markDirty(); } @@ -256,6 +265,14 @@ static bool samePar(StableDocIterator const & i1, StableDocIterator const & i2) // /////////////////////////////////////////////////////////////////////// +static bool samePar(StableDocIterator const & i1, StableDocIterator const & i2) +{ + StableDocIterator tmpi2 = i2; + tmpi2.pos() = i1.pos(); + return i1 == tmpi2; +} + + void Undo::Private::doRecordUndo(UndoKind kind, DocIterator const & cell, pit_type first_pit, pit_type last_pit, @@ -291,12 +308,13 @@ void Undo::Private::doRecordUndo(UndoKind kind, LYXERR(Debug::UNDO, "Create undo element of group " << group_id); // create the position information of the Undo entry UndoElement undo(kind, cur, cell, from, end, 0, 0, - buffer_.params(), isFullBuffer, group_id); + buffer_.params(), isFullBuffer, buffer_.isClean(), group_id); // fill in the real data to be saved if (cell.inMathed()) { // simply use the whole cell - undo.array = new MathData(cell.cell()); + MathData & ar = cell.cell(); + undo.array = new MathData(ar.buffer(), ar.begin(), ar.end()); } else { // some more effort needed here as 'the whole cell' of the // main Text _is_ the whole document. @@ -405,6 +423,10 @@ void Undo::Private::doTextUndoOrRedo(DocIterator & cur, UndoElementStack & stack LASSERT(undo.array == 0, /**/); cur = undo.cursor.asDocIterator(&buffer_); + if (undo.lyx_clean) + buffer_.markClean(); + else + buffer_.markDirty(); // Now that we're done with undo, we pop it off the stack. stack.pop(); } @@ -427,7 +449,7 @@ bool Undo::Private::textUndoOrRedo(DocIterator & cur, bool isUndoOperation) doTextUndoOrRedo(cur, stack, otherstack); // Adapt the new material to current buffer. - buffer_.updateLabels(); + buffer_.setBuffersForInsets(); // FIXME This shouldn't be here. return true; }