[LyX/master] Make undo action no-ops when the buffer is read-only

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sun Feb 20 18:18:11 UTC 2022


commit bfe98181169d9e697e515da974d9b6a15a06c940
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Sun Feb 20 19:48:13 2022 +0100

    Make undo action no-ops when the buffer is read-only
    
    Since the buffer cannot be modified, there is no point to record changes.
    Avoids marking buffer dirty after running "inset-forall".
---
 src/Undo.cpp |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/Undo.cpp b/src/Undo.cpp
index a870241..4e970df 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -374,6 +374,9 @@ void Undo::Private::recordUndo(UndoKind kind,
 	LASSERT(first_pit <= cell.lastpit(), return);
 	LASSERT(last_pit <= cell.lastpit(), return);
 
+	if (buffer_.isReadonly())
+		return;
+
 	doRecordUndo(kind, cell, first_pit, last_pit, cur,
 		undostack_);
 
@@ -408,6 +411,9 @@ void Undo::Private::doRecordUndoBufferParams(CursorData const & cur_before,
 
 void Undo::Private::recordUndoBufferParams(CursorData const & cur)
 {
+	if (buffer_.isReadonly())
+		return;
+
 	doRecordUndoBufferParams(cur, undostack_);
 
 	// next time we'll try again to combine entries if possible
@@ -517,6 +523,9 @@ void Undo::Private::doUndoRedoAction(CursorData & cur, UndoElementStack & stack,
 
 bool Undo::Private::undoRedoAction(CursorData & cur, bool isUndoOperation)
 {
+	if (buffer_.isReadonly())
+		return false;
+
 	undo_finished_ = true;
 
 	UndoElementStack & stack = isUndoOperation ?  undostack_ : redostack_;


More information about the lyx-cvs mailing list