branch: elpa/magit commit 4ccf2f658875325ae488173f6507be70263a2b35 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
magit--refresh-buffer*: Handle undisplayed buffer case more explicitly --- lisp/magit-mode.el | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el index c02fb3ea88..ecd34033c5 100644 --- a/lisp/magit-mode.el +++ b/lisp/magit-mode.el @@ -1112,20 +1112,22 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." (save-excursion (funcall fn))))))) (defun magit--refresh-buffer-get-positions () - (let ((buffer (current-buffer))) - (mapcan (lambda (window) - (with-selected-window window - (with-current-buffer buffer - (and-let* ((section (magit-section-at))) - `((,window - ,section - ,@(magit-section-get-relative-position section))))))) - (or (get-buffer-window-list buffer nil t) - (list (selected-window)))))) + (or (let ((buffer (current-buffer))) + (mapcan + (lambda (window) + (with-selected-window window + (with-current-buffer buffer + (and-let* ((section (magit-section-at))) + `((,window + ,section + ,@(magit-section-get-relative-position section))))))) + (get-buffer-window-list buffer nil t))) + (and-let* ((section (magit-section-at))) + `((nil ,section ,@(magit-section-get-relative-position section)))))) (defun magit--refresh-buffer-set-positions (positions) (pcase-dolist (`(,window ,section ,line ,char) positions) - (if (eq (current-buffer) (window-buffer window)) + (if window (with-selected-window window (magit-section-goto-successor section line char)) (magit-section-goto-successor section line char))))