Use UndoGroupHelper to track undo group lifetime

This commit is contained in:
Jean-Marc Lasgouttes 2017-11-29 14:55:56 +01:00
parent da79317ce2
commit f3656600f9

View File

@ -676,7 +676,7 @@ void GuiCompleter::tab()
} }
// Make undo possible // Make undo possible
cur.beginUndoGroup(); UndoGroupHelper ugh;
cur.recordUndo(); cur.recordUndo();
// If completion is active, at least complete by one character // If completion is active, at least complete by one character
@ -690,14 +690,11 @@ void GuiCompleter::tab()
hidePopup(); hidePopup();
hideInline(cur); hideInline(cur);
updateVisibility(false, false); updateVisibility(false, false);
cur.endUndoGroup();
return; return;
} }
docstring nextchar = completion.substr(prefix.size(), 1); docstring nextchar = completion.substr(prefix.size(), 1);
if (!cur.inset().insertCompletion(cur, nextchar, false)) { if (!cur.inset().insertCompletion(cur, nextchar, false))
cur.endUndoGroup();
return; return;
}
updatePrefix(cur); updatePrefix(cur);
// try to complete as far as it is unique // try to complete as far as it is unique
@ -717,7 +714,6 @@ void GuiCompleter::tab()
// redraw if needed // redraw if needed
if (cur.result().screenUpdate()) if (cur.result().screenUpdate())
gui_->bufferView().processUpdateFlags(cur.result().screenUpdate()); gui_->bufferView().processUpdateFlags(cur.result().screenUpdate());
cur.endUndoGroup();
} }