[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree cfc036a 133/195: Fix undo-tree-redo to avoid
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree cfc036a 133/195: Fix undo-tree-redo to avoid corrupting undo-tree state if redoing fails. |
Date: |
Sat, 28 Nov 2020 13:41:37 -0500 (EST) |
branch: externals/undo-tree
commit cfc036af8cb34c901af8b3c29fed71b5bf8e9018
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Fix undo-tree-redo to avoid corrupting undo-tree state if redoing fails.
primitive-undo can fail and throw an error for example if the buffer is
narrowed and we try to undo changes outside the visible region. Thus we need
to ensure buffer-undo-tree is not modified until *after* primitive-undo.
---
undo-tree.el | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index 0244053..ab8a584 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -2795,11 +2795,11 @@ changes within the current region."
(region-beginning) (region-end))))
(error "No further redo information for region"))
- ;; advance current node
+ ;; get next node (but DON'T advance current node in tree yet, in case
+ ;; redoing fails)
(setq current (undo-tree-current buffer-undo-tree)
- current (setf (undo-tree-current buffer-undo-tree)
- (nth (undo-tree-node-branch current)
- (undo-tree-node-next current))))
+ current (nth (undo-tree-node-branch current)
+ (undo-tree-node-next current)))
;; remove any GC'd elements from node's redo list
(decf (undo-tree-size buffer-undo-tree)
(undo-list-byte-size (undo-tree-node-redo current)))
@@ -2813,6 +2813,8 @@ changes within the current region."
(set-marker-insertion-type pos t))
(primitive-undo 1 (undo-tree-copy-list (undo-tree-node-redo current)))
(undo-boundary)
+ ;; advance current node in tree
+ (setf (undo-tree-current buffer-undo-tree) current)
;; if preserving old undo record, discard new undo entries that
;; `primitive-undo' has added to `buffer-undo-list', and remove any GC'd
- [elpa] externals/undo-tree 40c7065 108/195: Added undo-tree-visualizer-abort command, (continued)
- [elpa] externals/undo-tree 40c7065 108/195: Added undo-tree-visualizer-abort command, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 107d4c8 102/195: Allow visualizer to display relative timestamps., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 1561d8f 099/195: Preserve timestamps when generating diff for visualizer diff view., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 08db836 123/195: Fix bug in undo-tree-visualizer-select-left/right., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 6e5cc0f 104/195: Generate history save filename using a function, to allow customization., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 17568c3 113/195: Allow undo history save directory to be customized., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 965650c 127/195: Highlight node in visualizer corresponding to unmodified buffer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree ca9ec7b 105/195: Clear visualizer data / kill visualizer before saving history., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 270bc25 110/195: Added `~' to end of default history save-file name., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree d5a6148 120/195: Don't try to auto-save undo history if undo is disabled in buffer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree cfc036a 133/195: Fix undo-tree-redo to avoid corrupting undo-tree state if redoing fails.,
Stefan Monnier <=
- [elpa] externals/undo-tree bdfd73f 132/195: Ignore bogus buffer modification entries in undo changesets., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 6e0775d 139/195: Use define-derived-mode and define-minor-mode for undo-tree visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree d6fa2e7 152/195: Reinstate accidentally deleted file header., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8afead1 162/195: Add Maintainer line to package headers., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e9a9102 164/195: Throw error if interactive commands called outside undo-tree-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree ffd18cd 175/195: Refactor undo-list-transfer-to-tree again in attempt to mitigate GC races., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 941bfe5 190/195: Don't attempt to save undo history if history file is unwritable., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5a1ba84 017/195: Added standard Elisp package headers, including an extensive Commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 62e6097 044/195: Added undo-tree-save/restore-state-to/from-register commands and keybindings, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c638cbd 051/195: General code tidying and reorganisation., Stefan Monnier, 2020/11/28