Skip to content

Commit

Permalink
fix(vc-gutter): disable diff-hl-update-async in with-editor-mode
Browse files Browse the repository at this point in the history
`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: f2696d7
  • Loading branch information
hlissner committed Jul 10, 2024
1 parent c2c2416 commit 778fc9a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/ui/vc-gutter/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 778fc9a

Please sign in to comment.