Skip to content

Commit

Permalink
Mark the current node as the last-saved if buffer unmodified
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtsmith committed Mar 14, 2023
1 parent 84a4d2f commit a20f57a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 0 additions & 2 deletions test/test-2.txt

This file was deleted.

26 changes: 17 additions & 9 deletions vundo.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a20f57a

Please sign in to comment.