[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree 04b1a6f 054/195: Fixed bugs in history-discar
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree 04b1a6f 054/195: Fixed bugs in history-discarding logic. |
Date: |
Sat, 28 Nov 2020 13:41:20 -0500 (EST) |
branch: externals/undo-tree
commit 04b1a6f439117455e8ba502fabda359eed8963dd
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Fixed bugs in history-discarding logic.
---
undo-tree.el | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index 7cd22f9..b44dd5e 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -502,6 +502,7 @@
;; is displaying it
;; * fixed bug in `undo-tree-switch-branch'
;; * general code tidying and reorganisation
+;; * fixed bugs in history-discarding logic
;;
;; Version 0.1.6
;; * added `undo-tree-mode-lighter' customization option to allow the
@@ -990,15 +991,16 @@ Comparison is done with 'eq."
nil)
;; discard root
(t
+ ;; make child of root into new root
+ (setq node (setf (undo-tree-root buffer-undo-tree)
+ (car (undo-tree-node-next node))))
;; update undo-tree size
(decf (undo-tree-size buffer-undo-tree)
(+ (undo-list-byte-size (undo-tree-node-undo node))
(undo-list-byte-size (undo-tree-node-redo node))))
- ;; make child of root into new root
- (setf node (setf (undo-tree-root buffer-undo-tree)
- (car (undo-tree-node-next node)))
- (undo-tree-node-undo node) nil
- (undo-tree-node-redo node) nil)
+ ;; discard new root's undo data
+ (setf (undo-tree-node-undo node) nil
+ (undo-tree-node-redo node) nil)
;; if new root has branches, or new root is current node, next node
;; to discard is oldest leaf, otherwise it's new root
(if (or (> (length (undo-tree-node-next node)) 1)
@@ -1050,9 +1052,28 @@ set by `undo-limit', `undo-strong-limit' and
`undo-outer-limit'."
;; discard nodes until next node to discard would bring memory use
;; within `undo-limit'
(while (and node
+ ;; check first if last discard has brought us within
+ ;; `undo-limit', in case we can avoid more expensive
+ ;; `undo-strong-limit' calculation
+ ;; Note: this assumes undo-strong-limit > undo-limit;
+ ;; if not, effectively undo-strong-limit = undo-limit
+ (> (undo-tree-size buffer-undo-tree) undo-limit)
(> (- (undo-tree-size buffer-undo-tree)
- (undo-list-byte-size (undo-tree-node-undo node))
- (undo-list-byte-size (undo-tree-node-redo node)))
+ ;; if next node to discard is root, the memory we
+ ;; free-up comes from discarding changesets from its
+ ;; only child...
+ (if (eq node (undo-tree-root buffer-undo-tree))
+ (+ (undo-list-byte-size
+ (undo-tree-node-undo
+ (car (undo-tree-node-next node))))
+ (undo-list-byte-size
+ (undo-tree-node-redo
+ (car (undo-tree-node-next node)))))
+ ;; ...otherwise, it comes from discarding changesets
+ ;; from along with the node itself
+ (+ (undo-list-byte-size (undo-tree-node-undo node))
+ (undo-list-byte-size (undo-tree-node-redo node)))
+ ))
undo-limit))
(setq node (undo-tree-discard-node node)))
- [elpa] externals/undo-tree 3b1a83f 036/195: Fixed undo-tree-visualizer-quit to make it remove kill visualizer hook, (continued)
- [elpa] externals/undo-tree 3b1a83f 036/195: Fixed undo-tree-visualizer-quit to make it remove kill visualizer hook, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f3fc5cd 037/195: Modified undo-tree-undo/redo to always replace redo/undo entries, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f93420b 038/195: Remap undo-only to undo-tree-undo in undo-tree-map., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f8c3abf 039/195: Replaced save-excursion's with with-current-buffer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 723eeeb 040/195: Improved undo-tree-visualizer-quit behaviour, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8871f91 041/195: Added header containing git repository URL., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 3f5cc71 045/195: Updated commentary to include register commands,, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5176770 047/195: Added missing Change Log entry., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f44688d 048/195: Prevent debugger being called on "No further redo information" error., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bff9f31 049/195: Made undo-tree-visualizer-quit select window displaying parent buffer, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 04b1a6f 054/195: Fixed bugs in history-discarding logic.,
Stefan Monnier <=
- [elpa] externals/undo-tree 227473a 058/195: Modified undo-tree-node defstruct and macros to allow arbitrary meta-data, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 011e11e 061/195: Rebuild buffer-undo-list from tree when disabling undo-tree-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree a4b591b 059/195: Indicate registers storing undo-tree state in visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 6ab787bd 063/195: Added explanation of undo-in-region to Commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 99903d9 053/195: Made visualizer buffer name into a defconst,, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 2fd006f 055/195: Fixed bug in undo-tree-insert triggered by undo-tree-visualizer-set., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e569c17 056/195: Added missing changelog entry., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5d2f73c 057/195: Implemented support for marker entries in undo changesets!, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 0ed621d 062/195: Implemented undo-in-region., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8b1bae6 060/195: Implemented keyboard selection in visualizer., Stefan Monnier, 2020/11/28