[LyX/master] Fixup bf7f4d71: Let changeRefsIfUnique handle undo
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Sun Jan 12 21:07:44 UTC 2020
commit e340f46476000b933693772a5f3ce9d204504a0b
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Sun Jan 12 22:18:36 2020 +0100
Fixup bf7f4d71: Let changeRefsIfUnique handle undo
This allows for a much lower memory consumption than a plain
recordUnfoFullBuffer.
Related to bug 6494.
---
src/Buffer.cpp | 5 ++++-
src/Buffer.h | 2 +-
src/insets/InsetBibitem.cpp | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index bd3d63e..ffdd9b8 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -4039,14 +4039,17 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
return;
string const paramName = "key";
+ UndoGroupHelper ugh(this);
InsetIterator it = inset_iterator_begin(inset());
for (; it; ++it) {
if (it->lyxCode() != CITE_CODE)
continue;
InsetCommand * inset = it->asInsetCommand();
docstring const oldValue = inset->getParam(paramName);
- if (oldValue == from)
+ if (oldValue == from) {
+ undo().recordUndo(CursorData(it));
inset->setParam(paramName, to);
+ }
}
}
diff --git a/src/Buffer.h b/src/Buffer.h
index 0e1ec6b..04e9d60 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -624,7 +624,7 @@ public:
mutable UserMacroSet usermacros;
/// 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);
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp
index 424755b..1c1962c 100644
--- a/src/insets/InsetBibitem.cpp
+++ b/src/insets/InsetBibitem.cpp
@@ -155,7 +155,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd)
setParam("literal", p["literal"]);
if (p["key"] != old_key) {
- cur.recordUndoFullBuffer();
+ // changeRefsIfUnique handles undo
cur.bv().buffer().changeRefsIfUnique(old_key, p["key"]);
updateCommand(p["key"]);
cur.forceBufferUpdate();
More information about the lyx-cvs
mailing list