Skip to content

Commit efd30f4

Browse files
committed
Update diff-hl--update to synchronize overlays across indirect buffers
Identify the base buffer of the current file and iterate through all live buffers to apply diff highlighting to any indirect clones. Since overlays are buffer-local, this ensures that changes are visually reflected across all views of the same file while maintaining accurate point-dependent calculations in each.
1 parent 354a47b commit efd30f4

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

diff-hl.el

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -740,17 +740,23 @@ Return a list of line overlays used."
740740
reference
741741
(lambda (ref-changes)
742742
(let ((ref-changes (diff-hl-adjust-changes ref-changes changes))
743-
reuse)
744-
(with-current-buffer orig
745-
(diff-hl-remove-overlays)
746-
(let ((diff-hl-highlight-function
747-
diff-hl-highlight-reference-function)
748-
(diff-hl-fringe-face-function
749-
diff-hl-fringe-reference-face-function))
750-
(setq reuse (diff-hl--update-overlays ref-changes nil)))
751-
(diff-hl--update-overlays changes reuse)
752-
(when (not (or changes ref-changes))
753-
(diff-hl--autohide-margin))))))))))
743+
(base (or (buffer-base-buffer orig) orig)))
744+
(dolist (buf (buffer-list))
745+
(when (and (buffer-live-p buf)
746+
(or (eq buf base)
747+
(eq (buffer-base-buffer buf) base))
748+
(buffer-local-value 'diff-hl-mode buf))
749+
(with-current-buffer buf
750+
(let (reuse)
751+
(diff-hl-remove-overlays)
752+
(let ((diff-hl-highlight-function
753+
diff-hl-highlight-reference-function)
754+
(diff-hl-fringe-face-function
755+
diff-hl-fringe-reference-face-function))
756+
(setq reuse (diff-hl--update-overlays ref-changes nil)))
757+
(diff-hl--update-overlays changes reuse)
758+
(when (not (or changes ref-changes))
759+
(diff-hl--autohide-margin)))))))))))))
754760

755761
(defun diff-hl--resolve (value-or-buffer cb)
756762
(if (listp value-or-buffer)

0 commit comments

Comments
 (0)