feat(vc-gutter): shrink revert-hunk popup to contents

This commit is contained in:
Henrik Lissner 2022-08-09 17:54:18 +02:00
parent 2ff8228133
commit d55d7f3088
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -190,6 +190,18 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
(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: The revert popup consumes 50% of the frame, whether or not you're
;; reverting 2 lines or 20. This fix resizes the popup to match its contents.
(defadvice! +vc-gutter--shrink-popup-a (fn &rest args)
:around #'diff-hl-revert-hunk-1
(letf! ((refine-mode diff-auto-refine-mode)
(diff-auto-refine-mode t)
(defun diff-refine-hunk ()
(when refine-mode
(funcall diff-refine-hunk))
(shrink-window-if-larger-than-buffer)))
(apply fn args)))
;; UX: Don't delete the current hunk's indicators while we're editing ;; UX: Don't delete the current hunk's indicators while we're editing
(add-hook! 'diff-hl-flydiff-mode-hook (add-hook! 'diff-hl-flydiff-mode-hook
(defun +vc-gutter-init-flydiff-mode-h () (defun +vc-gutter-init-flydiff-mode-h ()