fix(vc-gutter): disable diff-hl-update-async in with-editor-mode

`diff-hl-update-async` was enabled in f2696d7, causing a regression
where with-editor buffers wouldn't get cleaned up properly. This would
particularly affect Magit's COMMIT_EDITMSG buffers. To quote jds on
Discord:

  It seems like after committing (with cc in the magit buffer), it
  leaves COMMIT_EDITMSG around. The next time I try & commit, a single c
  keypress immediately jumps to the old COMMIT_EDITMSG buffer, but it's
  inactive - C-c C-c closes that buffer but makes no change to git.

I opt for advice instead of find-file or with-editor-mode hooks to
restore normal behavior should with-editor-mode be later disabled
without the death of its buffer (not relevant to magit, specifically,
but it might be to other consumers of with-editor, now or in the
future).

Ref: dgutov/diff-hl#213
Amend: f2696d7302
This commit is contained in:
Henrik Lissner 2024-07-10 18:04:05 -04:00
parent c2c241666b
commit 778fc9ad3f
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -104,6 +104,16 @@
(add-hook 'magit-pre-refresh-hook #'diff-hl-magit-pre-refresh) (add-hook 'magit-pre-refresh-hook #'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook #'diff-hl-magit-post-refresh)) (add-hook 'magit-post-refresh-hook #'diff-hl-magit-post-refresh))
;; FIX: Fixes dgutov/diff-hl#213, where `diff-hl-update-async' stops
;; with-editor (and by extension, Magit COMMIT_EDITMSG buffers) buffers from
;; getting properly cleaned up.
(defadvice! +vc-gutter--inhibit-async-update-in-with-editor-a (fn &rest args)
:around #'diff-hl-update
(let ((diff-hl-update-async
(unless (bound-and-true-p with-editor-mode)
diff-hl-update-async)))
(apply fn args)))
;; FIX: The revert popup consumes 50% of the frame, whether or not you're ;; FIX: The revert popup consumes 50% of the frame, whether or not you're
;; reverting 2 lines or 20. This resizes the popup to match its contents. ;; reverting 2 lines or 20. This resizes the popup to match its contents.
(defadvice! +vc-gutter--shrink-popup-a (fn &rest args) (defadvice! +vc-gutter--shrink-popup-a (fn &rest args)