From bfe98181169d9e697e515da974d9b6a15a06c940 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sun, 20 Feb 2022 19:48:13 +0100 Subject: [PATCH] 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 file changed, 9 insertions(+) diff --git a/src/Undo.cpp b/src/Undo.cpp index a870241d13..4e970df5a0 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_; -- 2.39.5