@@ -86,7 +86,7 @@ status indicators."
8686 (progn
8787 (diff-hl-maybe-define-bitmaps)
8888 (set (make-local-variable 'diff-hl-dired-process-buffer ) nil )
89- (add-hook 'dired-after-readin-hook 'diff-hl-dired-update nil t ))
89+ (add-hook 'dired-after-readin-hook 'diff-hl-dired-update 10 t ))
9090 (remove-hook 'dired-after-readin-hook 'diff-hl-dired-update t )
9191 (diff-hl-dired-clear)))
9292
@@ -97,7 +97,6 @@ status indicators."
9797 (buffer (current-buffer ))
9898 dirs-alist files-alist)
9999 (when (and backend (not (memq backend diff-hl-dired-ignored-backends)))
100- (diff-hl-dired-clear)
101100 (if (buffer-live-p diff-hl-dired-process-buffer)
102101 (let ((proc (get-buffer-process diff-hl-dired-process-buffer)))
103102 (when proc (kill-process proc)))
@@ -117,22 +116,24 @@ status indicators."
117116 (with-current-buffer buffer
118117 (dolist (entry entries)
119118 (cl-destructuring-bind (file state &rest r) entry
120- ; ; Work around http://debbugs.gnu.org/18605
121- (setq file (replace-regexp-in-string " \\ ` " " " file))
122- (let ((type (plist-get
123- '( edited change added insert removed delete
124- unregistered unknown ignored ignored)
125- state)))
126- (if (string-match " \\ `\\ ([^/]+\\ )/" file)
127- (let* ((dir (match-string 1 file))
128- (value (cdr (assoc dir dirs-alist))))
119+ (unless (eq state 'up-to-date )
120+ ; ; Work around http://debbugs.gnu.org/18605
121+ (setq file (replace-regexp-in-string " \\ ` " " " file))
122+ (let ((type (plist-get '( edited change added insert removed delete
123+ unregistered unknown ignored ignored)
124+ state))
125+ (dirs (cl-loop with pos = 0
126+ while (string-match " /" file pos)
127+ do (setq pos (match-end 0 ))
128+ collect (substring file 0 (1- pos)))))
129+ (dolist (dir dirs)
130+ (let ((value (cdr (assoc dir dirs-alist))))
129131 (unless (eq value type)
130132 (cond
131- ((eq state 'up-to-date ))
132133 ((null value)
133134 (push (cons dir type) dirs-alist))
134135 ((not (eq type 'ignored ))
135- (setcdr (assoc dir dirs-alist) 'change )))))
136+ (setcdr (assoc dir dirs-alist) 'change ))))))
136137 (push (cons file type) files-alist)))))
137138 (unless more-to-come
138139 (diff-hl-dired-highlight-items
@@ -148,13 +149,14 @@ for DIR containing FILES. Call UPDATE-FUNCTION as entries are added."
148149
149150(defun diff-hl-dired-highlight-items (alist )
150151 " Highlight ALIST containing (FILE . TYPE) elements."
152+ (diff-hl-dired-clear) ; ; clear overlays right before drawing to avoid flicker
151153 (dolist (pair alist)
152154 (let ((file (car pair))
153155 (type (cdr pair)))
154156 (save-excursion
155157 (goto-char (point-min ))
156158 (when (and type (dired-goto-file-1
157- file (expand-file-name file) nil ))
159+ ( file-name-nondirectory file) (expand-file-name file) nil ))
158160 (let* ((diff-hl-fringe-bmp-function diff-hl-dired-fringe-bmp-function)
159161 (diff-hl-fringe-face-function 'diff-hl-dired-face-from-type )
160162 (o (diff-hl-add-highlighting type 'single )))
0 commit comments