branch: elpa/git-commit commit 348d9b98614c824be3e2f05eef5ab91d67f6695e Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
magit-section: Fix immediate selection highlighting Fixes a regression introduced in [1: bac25e73c]. 1: 2021-08-29 bac25e73c50fda8ed319cebb69f20e56f8bc7376 Avoid needless selection re-highlighting --- Documentation/RelNotes/3.4.0.org | 3 +++ lisp/magit-section.el | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/RelNotes/3.4.0.org b/Documentation/RelNotes/3.4.0.org index 5543fe9..a1b62bb 100644 --- a/Documentation/RelNotes/3.4.0.org +++ b/Documentation/RelNotes/3.4.0.org @@ -13,3 +13,6 @@ - Worktree commands and listing worktrees in the status buffer were broken inside remote repositories that are accessed using Tramp. #4326 + +- Due to a regression in v3.3.0 setting the mark did not highlight the + current and only selected section until a second section is selected. diff --git a/lisp/magit-section.el b/lisp/magit-section.el index 7f04a72..0706f9b 100644 --- a/lisp/magit-section.el +++ b/lisp/magit-section.el @@ -1243,12 +1243,14 @@ evaluated its BODY. Admittedly that's a bit of a hack." ;;; Highlight +(defvar-local magit-section-pre-command-region-p nil) (defvar-local magit-section-pre-command-section nil) (defvar-local magit-section-highlight-overlays nil) (defvar-local magit-section-highlighted-sections nil) (defvar-local magit-section-unhighlight-sections nil) (defun magit-section-pre-command-hook () + (setq magit-section-pre-command-region-p (region-active-p)) (setq magit-section-pre-command-section (magit-current-section))) (defun magit-section-deactivate-mark () @@ -1256,7 +1258,11 @@ evaluated its BODY. Admittedly that's a bit of a hack." (defun magit-section-update-highlight (&optional force) (let ((section (magit-current-section))) - (when (or force (not (eq magit-section-pre-command-section section))) + (when (or force + (cond ; `xor' wasn't added until 27.1. + ((not magit-section-pre-command-region-p) (region-active-p)) + ((not (region-active-p)) magit-section-pre-command-region-p)) + (not (eq magit-section-pre-command-section section))) (let ((inhibit-read-only t) (deactivate-mark nil) (selection (magit-region-sections)))