mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
fix(magit): reload related buffers after git ops
And when refocusing a frame.
This commit is contained in:
@ -101,12 +101,12 @@ window that already exists in that direction. It will split otherwise."
|
||||
(defun +magit--revert-buffer (buffer)
|
||||
(with-current-buffer buffer
|
||||
(kill-local-variable '+magit--stale-p)
|
||||
(when (and buffer-file-name (file-exists-p buffer-file-name))
|
||||
(if (buffer-modified-p (current-buffer))
|
||||
(when (bound-and-true-p vc-mode)
|
||||
(vc-refresh-state)
|
||||
(force-mode-line-update))
|
||||
(revert-buffer t t t)))))
|
||||
(when (magit-auto-revert-repository-buffer-p buffer)
|
||||
(when (bound-and-true-p vc-mode)
|
||||
(vc-refresh-state))
|
||||
(unless (buffer-modified-p buffer)
|
||||
(revert-buffer t t t))
|
||||
(force-mode-line-update))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +magit-mark-stale-buffers-h ()
|
||||
|
@ -39,16 +39,18 @@ Only has an effect in GUI Emacs.")
|
||||
magit-revision-insert-related-refs nil)
|
||||
(add-hook 'magit-process-mode-hook #'goto-address-mode)
|
||||
|
||||
(defadvice! +magit-revert-repo-buffers-deferred-a (&rest _)
|
||||
:after '(magit-checkout magit-branch-and-checkout)
|
||||
;; Since the project likely now contains new files, best we undo the
|
||||
;; projectile cache so it can be regenerated later.
|
||||
(projectile-invalidate-cache nil)
|
||||
;; Use a more efficient strategy to auto-revert buffers whose git state has
|
||||
;; changed: refresh the visible buffers immediately...
|
||||
(+magit-mark-stale-buffers-h))
|
||||
;; ...then refresh the rest only when we switch to them, not all at once.
|
||||
;; Since the project likely now contains new files, best we undo the
|
||||
;; projectile cache so it can be regenerated later.
|
||||
(add-hook! 'magit-post-refresh-hook
|
||||
(defun +magit-invalidate-projectile-cache-h ()
|
||||
(projectile-invalidate-cache nil)))
|
||||
;; Use a more efficient strategy to auto-revert buffers whose git state has
|
||||
;; changed: refresh the visible buffers immediately...
|
||||
(add-hook 'magit-post-refresh-hook #'+magit-mark-stale-buffers-h)
|
||||
;; ...then refresh the rest only when we switch to them or refocus the active
|
||||
;; frame, not all at once.
|
||||
(add-hook 'doom-switch-buffer-hook #'+magit-revert-buffer-maybe-h)
|
||||
(add-hook 'focus-in-hook #'+magit-mark-stale-buffers-h)
|
||||
|
||||
;; The default location for git-credential-cache is in
|
||||
;; ~/.cache/git/credential. However, if ~/.git-credential-cache/ exists, then
|
||||
|
Reference in New Issue
Block a user