branch: elpa/undo-fu
commit 2b1e53285a55ce50ca6fd60b050f2171e235d8f9
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>
Fix checkpoint initialization with undo data from undo-fu-session
---
changelog.rst | 2 ++
undo-fu.el | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/changelog.rst b/changelog.rst
index bf33687479..57787c5684 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -5,6 +5,8 @@ Change Log
- In development
+ - Fix undo checkpoint initialization when running for the first with
existing undo data.
+ This could happen when running undo immediately upon loading a file with
undo data from ``undo-fu-session``.
- Undo in *unconstrained* mode no longer uses ``undo-only``,
matching redo behavior.
- Raise an error when using undo commands when undo has been disabled for
the buffer.
diff --git a/undo-fu.el b/undo-fu.el
index a9ded87138..ac70a1ef67 100644
--- a/undo-fu.el
+++ b/undo-fu.el
@@ -358,6 +358,12 @@ Optional argument ARG the number of steps to undo."
'undo-fu-disable-checkpoint
'keyboard-quit)))
+ ;; Special case, for first execution, `was-undo-or-redo' may be true
+ ;; based on saved undo history, yet the `undo-fu--checkpoint' can be nil.
+ ;; In this case it's simplest to behave as if the last command was not
undo.
+ (when (and was-undo-or-redo undo-fu--respect (null undo-fu--checkpoint))
+ (setq was-undo-or-redo nil))
+
;; Reset the option to not respect the checkpoint
;; after running non-undo related commands.
(unless undo-fu--respect