From a20f57ad43197b0b3ee6dd5281758144bc52afaa Mon Sep 17 00:00:00 2001 From: JD Smith <93749+jdtsmith@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:11:21 -0400 Subject: [PATCH] Mark the current node as the last-saved if buffer unmodified --- test/test-2.txt | 2 -- vundo.el | 26 +++++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) delete mode 100644 test/test-2.txt diff --git a/test/test-2.txt b/test/test-2.txt deleted file mode 100644 index 1cf31fd..0000000 --- a/test/test-2.txt +++ /dev/null @@ -1,2 +0,0 @@ -○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○ - └──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○──○ diff --git a/vundo.el b/vundo.el index d698b4a..0165aaf 100644 --- a/vundo.el +++ b/vundo.el @@ -771,15 +771,23 @@ This function modifies `vundo--prev-mod-list', (unless (eq (vundo--latest-buffer-state mod-list) latest-state) (vundo--draw-tree mod-list)) - ;; Highlight current node. - (vundo--highlight-node (vundo--current-node mod-list)) - (goto-char (vundo-m-point (vundo--current-node mod-list))) - ;; Update the face of the last saved node. - (when-let (((and vundo-highlight-saved-nodes vundo--last-saved-idx)) - ((>= vundo--last-saved-idx 0)) - (last-saved-node (aref mod-list vundo--last-saved-idx)) - (pt (vundo-m-point last-saved-node))) - (put-text-property (1- pt) pt 'face 'vundo-last-saved)) + + (let ((current-node (vundo--current-node mod-list))) + ;; Highlight current node. + (vundo--highlight-node current-node) + (goto-char (vundo-m-point current-node)) + ;; Update the face of the last saved node. + (when vundo-highlight-saved-nodes + ;; if the associated buffer is unmodified, it is the latest + ;; saved (although it will have no prev-saved-ts). + (if (with-current-buffer orig-buffer (not (buffer-modified-p))) + (setq vundo--last-saved-idx (vundo-m-idx current-node))) + (when-let ((vundo--last-saved-idx) + ((>= vundo--last-saved-idx 0)) + (last-saved-node (aref mod-list vundo--last-saved-idx)) + (pt (vundo-m-point last-saved-node))) + (put-text-property (1- pt) pt 'face 'vundo-last-saved)))) + ;; Update cache. (setq vundo--prev-mod-list mod-list vundo--prev-mod-hash mod-hash