X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FUndo.cpp;h=33ab923e17f9b18cd5e733936e108c0a536e2c10;hb=a41d589e851a956ff27235841e6330bab552c0fe;hp=49f636cbb9eb87fbe99a2b88b224b92f483be6fb;hpb=51e80361b2880a9f2e3b9d888891ffd9498713a6;p=lyx.git diff --git a/src/Undo.cpp b/src/Undo.cpp index 49f636cbb9..33ab923e17 100644 --- a/src/Undo.cpp +++ b/src/Undo.cpp @@ -18,6 +18,7 @@ #include "Undo.h" #include "Buffer.h" +#include "BufferList.h" #include "BufferParams.h" #include "buffer_funcs.h" #include "Cursor.h" @@ -471,6 +472,7 @@ void Undo::Private::doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack, //LYXERR0("undo.array: " << *undo.array); LBUFERR(undo.array); dit.cell().swap(*undo.array); + dit.inset().setBuffer(buffer_); delete undo.array; undo.array = 0; } else { @@ -602,6 +604,14 @@ void Undo::endUndoGroup(CursorData const & cur_after) } +bool Undo::activeUndoGroup() const +{ + return d->group_level_ > 0 + && !d->undostack_.empty() + && d->undostack_.top().group_id == d->group_id_; +} + + void Undo::recordUndo(CursorData const & cur, UndoKind kind) { d->recordUndo(kind, cur, cur.pit(), cur.pit(), cur); @@ -661,7 +671,8 @@ UndoGroupHelper::UndoGroupHelper(Buffer * buf) : d(new UndoGroupHelper::Impl) UndoGroupHelper::~UndoGroupHelper() { for (Buffer * buf : d->buffers_) - buf->undo().endUndoGroup(); + if (theBufferList().isLoaded(buf) || theBufferList().isInternal(buf)) + buf->undo().endUndoGroup(); delete d; }