branch: elpa/magit
commit d1ac84ab23b639ff84eb7f7d02d45066cb6f77ba
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    Finalize inserted sections after moving to the current section
    
    After refreshing a buffer, and thus (re-)creating all sections,
    `magit-section-show' has to be called on the root section to set the
    correct visibility of all sections.  That function may also highlight
    the current section.  But when called at this time, point is at the
    beginning of the buffer, so the wrong section gets highlighted.
    
    Then, back in `magit-refresh-buffer' point is moved to the correct
    section, before `magit-section-update-highlight' is called, and since
    a different section is current now, highlighting has to be updated.
    
    Avoiding to highlight twice was the motivation for this change, but a
    later commit prevents it differently.  Despite that making this change
    not strictly necessary, it feels right to move the `magit-section-show'
    call to `magit-refresh-buffer'.
---
 lisp/magit-mode.el    | 2 ++
 lisp/magit-section.el | 4 +---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index eb73f7ff21..56eb7585cb 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -1108,6 +1108,8 @@ Run hooks `magit-pre-refresh-hook' and 
`magit-post-refresh-hook'."
             (with-current-buffer buffer
               (let ((magit-section-movement-hook nil))
                 (apply #'magit-section-goto-successor args)))))
+        (let ((magit-section-cache-visibility nil))
+          (magit-section-show magit-root-section))
         (run-hooks 'magit-refresh-buffer-hook)
         (magit-section-update-highlight)
         (set-buffer-modified-p nil)
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index d18e7e0e09..3d0b2d683a 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -1452,9 +1452,7 @@ anything this time around.
       (magit-map-sections
        (lambda (section)
          (oset section start (copy-marker (oref section start) t))
-         (oset section end   (copy-marker (oref section end)   t)))))
-    (let ((magit-section-cache-visibility nil))
-      (magit-section-show obj)))
+         (oset section end   (copy-marker (oref section end)   t))))))
    (t
     (magit-section--set-section-properties obj)
     (magit-section-maybe-add-heading-map obj)

Reply via email to