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

    magit-region-sections: Prevent flashing the selection overlay here
    
    This improves upon [1: 2d5ad5d2f9].  When clicking on a diff related
    list heading, that section is now immediately highlighted as the current
    section (we only want to prevent highlighting as selected).  In practice
    the difference is barely noticeable, unless one clicks and holds,
    without moving.
    
    The second call to `mouse-drag-region' in `magit-diff-highlight-list' is
    still necessary to ensure child sections are immediately highlighted as
    current.
    
    1: 2017-11-09 2d5ad5d2f9d9176ee1c17617080bef5dd6c6bf64
       Don't flash selection on mouse click
---
 lisp/magit-diff.el    |  6 ++----
 lisp/magit-section.el | 12 +++++++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 663bc38f6c..30502aaa92 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -3316,8 +3316,7 @@ are highlighted."
       (let ((beg (oref section start))
             (cnt (oref section content))
             (end (oref section end)))
-        (when (or (eq this-command #'mouse-drag-region)
-                  (not selection))
+        (unless selection
           (unless (and (region-active-p)
                        (<= (region-beginning) beg))
             (magit-section-make-overlay beg cnt 'magit-section-highlight))
@@ -3346,8 +3345,7 @@ are highlighted."
    (or (oref section content)
        (oref section end))
    (pcase (list (oref section type)
-                (and (member section selection)
-                     (not (eq this-command #'mouse-drag-region))))
+                (and (member section selection) t))
      ('(file     t) 'magit-diff-file-heading-selection)
      ('(file   nil) 'magit-diff-file-heading-highlight)
      ('(module   t) 'magit-diff-file-heading-selection)
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index c61e77f0a3..87d16fc9d1 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -1763,8 +1763,7 @@ This function is necessary to ensure that a 
representation of
 such a region is visible.  If neither of these functions were
 part of the hook variable, then such a region would be
 invisible."
-  (when (and selection
-             (not (and (eq this-command 'mouse-drag-region))))
+  (when selection
     (dolist (sibling selection)
       (with-slots (start content end heading-selection-face) sibling
         (magit-section-make-overlay start (or content end)
@@ -2085,7 +2084,14 @@ forms CONDITION can take."
               (rend (region-end))
               (sbeg (magit-section-at rbeg))
               (send (magit-section-at rend)))
-         (and send
+         ;; It should be possible to select a single section using
+         ;; `set-mark-command', so don't use `use-region-p' above.
+         ;; We still have to prevent the selection overlay from
+         ;; being flashed when clicking inside a section, which
+         ;; the first condition accomplishes:
+         (and (or (not (eq this-command #'mouse-drag-region))
+                  (> rend rbeg))
+              send
               (not (eq send magit-root-section))
               (not (and (eq send sbeg)
                         (or multiple

Reply via email to