commit f6430577798b604a11616c2191e664d56efa7cfb
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Thu Jun 20 17:25:25 2024 +0200

    Remove useless cursor parameter to global undo actions
    
    Add a Cursor-less version of Undo::recordUndoBufferParams (we don't
    use an optional arument to avoir #includ'ing Cursor.h).
    
    The version with CursorData parameter has been kept for the case of
    local dictionary lfuns that have some kind of locality.
    
    Remove Cursor argument to Undo::recordUndoFullBuffer().
---
 src/Buffer.cpp | 14 +++++++-------
 src/Cursor.cpp |  2 +-
 src/Undo.cpp   | 13 ++++++++++---
 src/Undo.h     | 10 ++++++----
 4 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 0f7560c8e4..e95d0edcc8 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2865,7 +2865,7 @@ bool Buffer::branchActivationDispatch(FuncCode act, 
docstring const & branch)
                        "Please make sure to save the master."), branch), true);
 
        UndoGroupHelper ugh(buf);
-       buf->undo().recordUndoBufferParams(CursorData());
+       buf->undo().recordUndoBufferParams();
        our_branch->setSelected(activate);
        // cur.forceBufferUpdate() is not enough)
        buf->updateBuffer();
@@ -3029,7 +3029,7 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
                                        msg += ("\n");
                                msg += bformat(_("Branch \"%1$s\" already 
exists."), branch_name);
                        } else {
-                               undo().recordUndoBufferParams(CursorData());
+                               undo().recordUndoBufferParams();
                                branch_list.add(branch_name);
                                branch = branch_list.find(branch_name);
                                if (branch)
@@ -3089,13 +3089,13 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
 
        case LFUN_CHANGES_TRACK:
                if (params().save_transient_properties)
-                       undo().recordUndoBufferParams(CursorData());
+                       undo().recordUndoBufferParams();
                params().track_changes = !params().track_changes;
                break;
 
        case LFUN_CHANGES_OUTPUT:
                if (params().save_transient_properties)
-                       undo().recordUndoBufferParams(CursorData());
+                       undo().recordUndoBufferParams();
                params().output_changes = !params().output_changes;
                if (params().output_changes) {
                        bool xcolorulem = LaTeXFeatures::isAvailable("ulem") &&
@@ -3113,17 +3113,17 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
 
        case LFUN_BUFFER_TOGGLE_COMPRESSION:
                // turn compression on/off
-               undo().recordUndoBufferParams(CursorData());
+               undo().recordUndoBufferParams();
                params().compressed = !params().compressed;
                break;
 
        case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC:
-               undo().recordUndoBufferParams(CursorData());
+               undo().recordUndoBufferParams();
                params().output_sync = !params().output_sync;
                break;
 
        case LFUN_BUFFER_ANONYMIZE: {
-               undo().recordUndoFullBuffer(CursorData());
+               undo().recordUndoFullBuffer();
                CursorData cur(doc_iterator_begin(this));
                for ( ; cur ; cur.forwardPar())
                        cur.paragraph().anonymize();
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index c1e55954b5..c53a7307bf 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -647,7 +647,7 @@ void CursorData::recordUndoInset(Inset const * inset) const
 
 void CursorData::recordUndoFullBuffer() const
 {
-       buffer()->undo().recordUndoFullBuffer(*this);
+       buffer()->undo().recordUndoFullBuffer();
 }
 
 
diff --git a/src/Undo.cpp b/src/Undo.cpp
index ddc7025e1c..8dcffff32b 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -672,17 +672,24 @@ void Undo::recordUndoBufferParams(CursorData const & cur)
 }
 
 
-void Undo::recordUndoFullBuffer(CursorData const & cur)
+void Undo::recordUndoBufferParams()
+{
+       d->recordUndoBufferParams(CursorData());
+}
+
+
+void Undo::recordUndoFullBuffer()
 {
        // This one may happen outside of the main undo group, so we
        // put it in its own subgroup to avoid complaints.
        beginUndoGroup();
        d->recordUndo(ATOMIC_UNDO, doc_iterator_begin(&d->buffer_),
-                     0, d->buffer_.paragraphs().size() - 1, cur);
-       d->recordUndoBufferParams(cur);
+                     0, d->buffer_.paragraphs().size() - 1, CursorData());
+       d->recordUndoBufferParams(CursorData());
        endUndoGroup();
 }
 
+
 /// UndoGroupHelper class stuff
 
 class UndoGroupHelper::Impl {
diff --git a/src/Undo.h b/src/Undo.h
index fbfb9e7dbb..b6d84569c5 100644
--- a/src/Undo.h
+++ b/src/Undo.h
@@ -116,11 +116,13 @@ public:
        /// prepare undo for the inset containing the cursor
        void recordUndoInset(CursorData const & cur, Inset const * inset);
 
-       /// Convenience: record undo for buffer parameters
-       void recordUndoBufferParams(CursorData const & cur);
+       /// Prepare undo for the whole buffer (but not the buffer parameters)
+       void recordUndoFullBuffer();
 
-       /// Convenience: prepare undo for the whole buffer
-       void recordUndoFullBuffer(CursorData const & cur);
+       /// Record undo for buffer parameters, with or without pre-undo
+       /// cursor
+       void recordUndoBufferParams(CursorData const & cur);
+       void recordUndoBufferParams();
 
 private:
        struct Private;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to