diff --git a/diff-hl.el b/diff-hl.el index b122fe25..9ed484ca 100644 --- a/diff-hl.el +++ b/diff-hl.el @@ -638,7 +638,7 @@ contents as they are (or would be) after applying the changes in NEW." (run-hook-with-args-until-success 'diff-hl-async-inhibit-functions default-directory)))) -(defvar diff-hl-timer nil) +(defvar-local diff-hl-timer nil) (defun diff-hl-update () "Updates the diff-hl overlay." diff --git a/test/diff-hl-test.el b/test/diff-hl-test.el index db6ce19c..d757b873 100644 --- a/test/diff-hl-test.el +++ b/test/diff-hl-test.el @@ -79,6 +79,15 @@ (diff-hl-test-teardown)))) (put 'diff-hl-deftest 'lisp-indent-function 'defun) +(ert-deftest diff-hl-update-once-schedules-per-buffer () + (let ((diff-hl-timer nil) + (calls 0)) + (cl-letf (((symbol-function 'run-with-idle-timer) + (lambda (&rest _) (cl-incf calls)))) + (with-temp-buffer (diff-hl-update-once)) + (with-temp-buffer (diff-hl-update-once))) + (should (= calls 2)))) + (diff-hl-deftest diff-hl-insert () (diff-hl-test-in-source (goto-char (point-max))