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().
This commit is contained in:
Jean-Marc Lasgouttes 2024-06-20 17:25:25 +02:00
parent c7c16fe9fa
commit f643057779
4 changed files with 24 additions and 15 deletions

View File

@ -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();

View File

@ -647,7 +647,7 @@ void CursorData::recordUndoInset(Inset const * inset) const
void CursorData::recordUndoFullBuffer() const
{
buffer()->undo().recordUndoFullBuffer(*this);
buffer()->undo().recordUndoFullBuffer();
}

View File

@ -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 {

View File

@ -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;