string const argument = to_utf8(func.argument());
// We'll set this back to false if need be.
bool dispatched = true;
- undo().beginUndoGroup();
+ // This handles undo groups automagically
+ UndoGroupHelper ugh(this);
switch (func.action()) {
case LFUN_BUFFER_TOGGLE_READ_ONLY:
break;
}
dr.dispatched(dispatched);
- undo().endUndoGroup();
}
#include "Undo.h"
#include "Buffer.h"
+#include "BufferList.h"
#include "BufferParams.h"
#include "buffer_funcs.h"
#include "Cursor.h"
UndoGroupHelper::~UndoGroupHelper()
{
for (Buffer * buf : d->buffers_)
- buf->undo().endUndoGroup();
+ if (theBufferList().isLoaded(buf) || theBufferList().isInternal(buf))
+ buf->undo().endUndoGroup();
delete d;
}
if (current_view_ && current_view_->currentBufferView()) {
current_view_->currentBufferView()->cursor().saveBeforeDispatchPosXY();
buffer = ¤t_view_->currentBufferView()->buffer();
- if (buffer)
- buffer->undo().beginUndoGroup();
}
+ // This handles undo groups automagically
+ UndoGroupHelper ugh(buffer);
DispatchResult dr;
// redraw the screen at the end (first of the two drawing steps).
dispatch(cmd, dr);
updateCurrentView(cmd, dr);
- // the buffer may have been closed by one action
- if (theBufferList().isLoaded(buffer) || theBufferList().isInternal(buffer))
- buffer->undo().endUndoGroup();
-
d->dispatch_result_ = dr;
return d->dispatch_result_;
}
// FIXME: this LFUN should also work without any view.
Buffer * buffer = (current_view_ && current_view_->documentBufferView())
? &(current_view_->documentBufferView()->buffer()) : 0;
- if (buffer)
- buffer->undo().beginUndoGroup();
+ // This handles undo groups automagically
+ UndoGroupHelper ugh(buffer);
while (!arg.empty()) {
string first;
arg = split(arg, first, ';');
func.setOrigin(cmd.origin());
dispatch(func);
}
- // the buffer may have been closed by one action
- if (theBufferList().isLoaded(buffer) || theBufferList().isInternal(buffer))
- buffer->undo().endUndoGroup();
break;
}
// We need a non-const buffer object.
Buffer & buf = const_cast<BufferView *>(bufferview())->buffer();
// There may be several undo records; group them (bug #8998)
- buf.undo().beginUndoGroup();
+ // This handles undo groups automagically
+ UndoGroupHelper ugh(&buf);
// This must come first so that a language change is correctly noticed
setLanguage();
// If we used an LFUN, we would not need these two lines:
BufferView * bv = const_cast<BufferView *>(bufferview());
bv->processUpdateFlags(Update::Force | Update::FitCursor);
-
- // Don't forget to close the group. Note that it is important
- // to check that there is no early return in the method.
- buf.undo().endUndoGroup();
}
InsetGraphicsParams params;
InsetGraphics::string2params(argument, b, params);
- b.undo().beginUndoGroup();
+ // This handles undo groups automagically
+ UndoGroupHelper ugh(&b);
Inset & inset = b.inset();
InsetIterator it = inset_iterator_begin(inset);
InsetIterator const end = inset_iterator_end(inset);
}
}
}
- b.undo().endUndoGroup();
}
if (label == old_label)
return;
- buffer().undo().beginUndoGroup();
+ // This handles undo groups automagically
+ UndoGroupHelper ugh(&buffer());
if (cursor)
cursor->recordUndo();
setParam("name", label);
updateReferences(old_label, label);
- buffer().undo().endUndoGroup();
}
* USER INTERFACE
+- Improve Undo for operations that act on several buffers (bug 10823).
* INTERNALS