From 778fc9ad3f7a2cc3e8fdeef2b2988bf0e0c07b26 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 10 Jul 2024 18:04:05 -0400 Subject: [PATCH] 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: f2696d730200 --- modules/ui/vc-gutter/config.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/ui/vc-gutter/config.el b/modules/ui/vc-gutter/config.el index f88ff4567cd..ab5398d7317 100644 --- a/modules/ui/vc-gutter/config.el +++ b/modules/ui/vc-gutter/config.el @@ -104,6 +104,16 @@ (add-hook 'magit-pre-refresh-hook #'diff-hl-magit-pre-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 ;; reverting 2 lines or 20. This resizes the popup to match its contents. (defadvice! +vc-gutter--shrink-popup-a (fn &rest args)