branch: elpa/magit
commit 725efbd24964819cce3f09ab1aec0eb318a326eb
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-refresh-buffer: Reset magit-section-focused-sections
This variable is also reset in `magit-section-pre-command-hook' but that
only affects the current buffer. We also have to reset this cache when
refreshing a buffer, otherwise it would continue to track sections from
the previous generation, which no longer exist.
For example, if point is on an unstage hunk in the status and the user
invokes a commit command, then the commit message buffer is current when
the commit is finalized. In that case `magit-section-update-paint' was
called for two section in the status buffer; the previous generation
hunk (which ended up being a noop) and the actually focused hunk (which
was not included in the value returned by `magit-focused-sections',
because that cache had not been invalidated yet, and thus got painted
as unfocused).
---
lisp/magit-mode.el | 1 +
lisp/magit-section.el | 1 +
2 files changed, 2 insertions(+)
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index d53e468bfea..d8e00d055f4 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -1099,6 +1099,7 @@ Run hooks `magit-pre-refresh-hook' and
`magit-post-refresh-hook'."
(setq magit-section-highlight-overlays nil)
(setq magit-section-selection-overlays nil)
(setq magit-section-highlighted-sections nil)
+ (setq magit-section-focused-sections nil)
(let ((inhibit-read-only t))
(erase-buffer)
(save-excursion
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index e162982a13d..bac89376a2b 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -306,6 +306,7 @@ no effect. This also has no effect for Emacs >= 28, where
(defvar-local magit-section-pre-command-region-p nil)
(defvar-local magit-section-pre-command-section nil)
+
(defvar-local magit-section-highlight-force-update nil)
(defvar-local magit-section-highlight-overlays nil)
(defvar-local magit-section-selection-overlays nil)