fix(vc-gutter): toggle diff-hl-margin-mode in tty frames

Fix: #8001
This commit is contained in:
Henrik Lissner 2024-08-22 15:14:36 -04:00
parent d309dcad27
commit e59023b843
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -193,4 +193,19 @@ Respects `diff-hl-disable-on-remote'."
(defadvice! +vc-gutter--kill-diff-hl-thread-a (&optional buf)
:before #'kill-buffer
(with-current-buffer (or buf (current-buffer))
(+vc-gutter--kill-thread t))))
(+vc-gutter--kill-thread t)))
;; HACK: diff-hl won't be visible in TTY frames, but there's no simple way to
;; use the fringe in GUI Emacs and use the margin in the terminal *AND*
;; support daemon users, so we need more than a static `display-graphic-p'
;; check at startup.
(when (modulep! :os tty)
(put 'diff-hl-mode 'last (display-graphic-p))
(add-hook! 'doom-switch-window-hook
(defun +vc-gutter-use-margins-in-tty-h ()
(let ((graphic? (display-graphic-p)))
(unless (and global-diff-hl-mode (eq (get 'diff-hl-mode 'last) graphic?))
(global-diff-hl-mode -1)
(diff-hl-margin-mode (if graphic? -1 +1))
(global-diff-hl-mode +1)
(put 'diff-hl-mode 'last graphic?)))))))