Fixup bf7f4d71: Let changeRefsIfUnique handle undo

This allows for a much lower memory consumption than a plain
recordUnfoFullBuffer.

Related to bug 6494.
This commit is contained in:
Jean-Marc Lasgouttes 2020-01-12 22:18:36 +01:00
parent 0f0ed8073a
commit e340f46476
3 changed files with 6 additions and 3 deletions

View File

@ -4039,14 +4039,17 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
return; return;
string const paramName = "key"; string const paramName = "key";
UndoGroupHelper ugh(this);
InsetIterator it = inset_iterator_begin(inset()); InsetIterator it = inset_iterator_begin(inset());
for (; it; ++it) { for (; it; ++it) {
if (it->lyxCode() != CITE_CODE) if (it->lyxCode() != CITE_CODE)
continue; continue;
InsetCommand * inset = it->asInsetCommand(); InsetCommand * inset = it->asInsetCommand();
docstring const oldValue = inset->getParam(paramName); docstring const oldValue = inset->getParam(paramName);
if (oldValue == from) if (oldValue == from) {
undo().recordUndo(CursorData(it));
inset->setParam(paramName, to); inset->setParam(paramName, to);
}
} }
} }

View File

@ -624,7 +624,7 @@ public:
mutable UserMacroSet usermacros; mutable UserMacroSet usermacros;
/// Replace the inset contents for insets which InsetCode is equal /// Replace the inset contents for insets which InsetCode is equal
/// to the passed \p inset_code. /// to the passed \p inset_code. Handles undo.
void changeRefsIfUnique(docstring const & from, docstring const & to); void changeRefsIfUnique(docstring const & from, docstring const & to);
/// get source code (latex/docbook) for some paragraphs, or all paragraphs /// get source code (latex/docbook) for some paragraphs, or all paragraphs

View File

@ -155,7 +155,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd)
setParam("literal", p["literal"]); setParam("literal", p["literal"]);
if (p["key"] != old_key) { if (p["key"] != old_key) {
cur.recordUndoFullBuffer(); // changeRefsIfUnique handles undo
cur.bv().buffer().changeRefsIfUnique(old_key, p["key"]); cur.bv().buffer().changeRefsIfUnique(old_key, p["key"]);
updateCommand(p["key"]); updateCommand(p["key"]);
cur.forceBufferUpdate(); cur.forceBufferUpdate();