branch: externals/diff-hl commit 09ffe8dce1af5fe32ab6e12e3a424504db365700 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
Introduce diff-hl-update-once, to avoid diffing twice in normal-mode Fixes #152 --- diff-hl.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/diff-hl.el b/diff-hl.el index 0f59263..11d9850 100644 --- a/diff-hl.el +++ b/diff-hl.el @@ -358,6 +358,15 @@ performance when viewing such files in certain conditions." (overlay-put h 'insert-in-front-hooks hook) (overlay-put h 'insert-behind-hooks hook))))))))) +(defvar-local diff-hl--modified-tick nil) + +(put 'diff-hl--modified-tick 'permanent-local t) + +(defun diff-hl-update-once () + (unless (equal diff-hl--modified-tick (buffer-chars-modified-tick)) + (diff-hl-update) + (setq diff-hl--modified-tick (buffer-chars-modified-tick)))) + (defun diff-hl-add-highlighting (type shape) (let ((o (make-overlay (point) (point)))) (overlay-put o 'diff-hl t) @@ -571,7 +580,7 @@ The value of this variable is a mode line template as in ;; let's wait until the state information is ;; saved, in order not to fetch it twice. 'find-file-hook) - 'diff-hl-update t t) + 'diff-hl-update-once t t) (add-hook 'vc-checkin-hook 'diff-hl-update nil t) ;; https://github.com/magit/magit/issues/603 (add-hook 'magit-revert-buffer-hook 'diff-hl-update nil t)