branch: elpa/undo-fu
commit 49cca61343e5fc80347a7b1f7d8692a49752575d
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>
Fix unconstrained redo trapping the user at the end of the chain
Add a special check for this, allowing you to undo out of this state.
---
changelog.rst | 2 ++
undo-fu.el | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/changelog.rst b/changelog.rst
index 57787c5684..9ed97ea73b 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -5,6 +5,8 @@ Change Log
- In development
+ - Fix continual redo in unconstrained mode trapping the user in a state
+ where neither undo or redo can be performed.
- 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``,
diff --git a/undo-fu.el b/undo-fu.el
index ac70a1ef67..120fd1b39d 100644
--- a/undo-fu.el
+++ b/undo-fu.el
@@ -353,6 +353,7 @@ Optional argument ARG the number of steps to undo."
(let*
( ;; Assign for convenience.
(was-undo-or-redo (undo-fu--was-undo-or-redo))
+ (was-redo (and was-undo-or-redo undo-fu--was-redo))
(undo-fu-quit-command
(if undo-fu-ignore-keyboard-quit
'undo-fu-disable-checkpoint
@@ -399,6 +400,15 @@ Optional argument ARG the number of steps to undo."
(steps (or arg 1))
(last-command
(cond
+ ;; Special case, to avoid being locked out of the undo-redo chain.
+ ;; Without this, continuously redoing will end up in a state where
undo & redo fails.
+ ;;
+ ;; Detect this case and break the chain. Only do this when
previously redoing
+ ;; otherwise undo will reverse immediately once it reaches the
beginning,
+ ;; which we don't want even when unconstrained,
+ ;; as we don't want to present the undo chain as infinite in
either direction.
+ ((and was-redo (null undo-fu--respect) (eq t pending-undo-list))
+ 'ignore)
(was-undo-or-redo
;; Checked by the undo function.
'undo)