pit_type const lastpit = parit.lastpit();
for ( ; parit.pit() <= lastpit ; ++parit.pit()) {
// reduce depth if necessary
- parit->params().depth(min(parit->params().depth(), maxdepth));
+ if (parit->params().depth() > maxdepth) {
+ /** FIXME: this function is const, but
+ * nevertheless it modifies the buffer. To be
+ * cleaner, one should modify the buffer in
+ * another function, which is actually
+ * non-const. This would however be costly in
+ * terms of code duplication.
+ */
+ const_cast<Buffer *>(this)->undo().recordUndo(parit);
+ parit->params().depth(maxdepth);
+ }
maxdepth = parit->getMaxDepthAfter();
if (utype == OutputUpdate) {
void GuiApplication::dispatch(FuncRequest const & cmd)
{
- if (current_view_ && current_view_->currentBufferView())
+ Buffer * buffer = 0;
+ if (current_view_ && current_view_->currentBufferView()) {
current_view_->currentBufferView()->cursor().saveBeforeDispatchPosXY();
+ buffer = ¤t_view_->currentBufferView()->buffer();
+ if (buffer)
+ buffer->undo().beginUndoGroup();
+ }
DispatchResult dr;
// redraw the screen at the end (first of the two drawing steps).
dr.screenUpdate(Update::FitCursor);
dispatch(cmd, dr);
updateCurrentView(cmd, dr);
+
+ // the buffer may have been closed by one action
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().endUndoGroup();
}