Skip to content

Commit

Permalink
magit-section-post-command-hook: Skip menu work if wrong buffer selected
Browse files Browse the repository at this point in the history
The command may have used `set-window-buffer' to change the window's
buffer without changing the current buffer.  Previously that would
have resulted in an error because `magit-section-post-command-hook'
was not prepared to handle this situation, now we simply skip the
menu related work in this case.  Also see #5098.
  • Loading branch information
LemonBreezes authored and tarsius committed Feb 21, 2024
1 parent 09961f6 commit 039a180
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lisp/magit-section.el
Original file line number Diff line number Diff line change
Expand Up @@ -1635,10 +1635,14 @@ evaluated its BODY. Admittedly that's a bit of a hack."
(setq magit-section-pre-command-section (magit-current-section)))

(defun magit-section-post-command-hook ()
(cursor-sensor-move-to-tangible (selected-window))
(when (or magit--context-menu-buffer
magit--context-menu-section)
(magit-menu-highlight-point-section))
(let ((window (selected-window)))
;; The command may have used `set-window-buffer' to change
;; the window's buffer without changing the current buffer.
(when (eq (current-buffer) (window-buffer window))
(cursor-sensor-move-to-tangible window)
(when (or magit--context-menu-buffer
magit--context-menu-section)
(magit-menu-highlight-point-section))))
(unless (memq this-command '(magit-refresh magit-refresh-all))
(magit-section-update-highlight)))

Expand Down

0 comments on commit 039a180

Please sign in to comment.