branch: externals/diff-hl
commit dee6a724128a860f50108d886b9580794c300d67
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>

    diff-hl--when-done: Make sure to avoid running callback when process killed
    
    By keeping the process reference and passing it up.
---
 diff-hl.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/diff-hl.el b/diff-hl.el
index c032ef41b9..3d822f61cb 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -717,8 +717,8 @@ Return a list of line overlays used."
                         #'diff-hl-changes-from-buffer
                         cb)))
 
-(defun diff-hl--when-done (buffer get-value callback)
-  (let ((proc (get-buffer-process buffer)))
+(defun diff-hl--when-done (buffer get-value callback &optional proc)
+  (let ((proc (or proc (get-buffer-process buffer))))
     (cond
      ;; If there's no background process, just execute the code.
      ((or (null proc) (eq (process-status proc) 'exit))
@@ -733,9 +733,9 @@ Return a list of line overlays used."
      ((eq (process-status proc) 'run)
       (set-process-sentinel
        proc
-       (lambda (_proc _status)
+       (lambda (proc _status)
          ;; Delegate to the parent cond for decision logic.
-         (diff-hl--when-done buffer get-value callback))))
+         (diff-hl--when-done buffer get-value callback proc))))
      ;; Maybe we should ignore all other states as well.
      (t (error "Unexpected process state")))))
 

Reply via email to