@@ -740,9 +740,31 @@ Return a list of line overlays used."
740740(defun diff-hl--resolve (value-or-buffer cb )
741741 (if (listp value-or-buffer)
742742 (funcall cb value-or-buffer)
743- (with-current-buffer value-or-buffer
744- (vc-run-delayed
745- (funcall cb (diff-hl-changes-from-buffer (current-buffer )))))))
743+ (diff-hl--when-done value-or-buffer
744+ #'diff-hl-changes-from-buffer
745+ cb)))
746+
747+ (defun diff-hl--when-done (buffer get-value callback &optional proc )
748+ (let ((proc (or proc (get-buffer-process buffer))))
749+ (cond
750+ ; ; If there's no background process, just execute the code.
751+ ((or (null proc) (eq (process-status proc) 'exit ))
752+ ; ; Make sure we've read the process's output before going further.
753+ (when proc (accept-process-output proc))
754+ (when (get-buffer buffer)
755+ (with-current-buffer buffer
756+ (funcall callback (funcall get-value buffer)))))
757+ ; ; If process was deleted, we ignore it.
758+ ((eq (process-status proc) 'signal ))
759+ ; ; If a process is running, set the sentinel.
760+ ((eq (process-status proc) 'run )
761+ (set-process-sentinel
762+ proc
763+ (lambda (proc _status )
764+ ; ; Delegate to the parent cond for decision logic.
765+ (diff-hl--when-done buffer get-value callback proc))))
766+ ; ; Maybe we should ignore all other states as well.
767+ (t (error " Unexpected process state " )))))
746768
747769(defun diff-hl--autohide-margin ()
748770 (let ((width-var (intern (format " %s -margin-width" diff-hl-side))))
0 commit comments