emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/diff-hl 6b7ca8c: Avoid unexpected scrolling


From: ELPA Syncer
Subject: [elpa] externals/diff-hl 6b7ca8c: Avoid unexpected scrolling
Date: Mon, 27 Sep 2021 21:57:15 -0400 (EDT)

branch: externals/diff-hl
commit 6b7ca8c310ec1c1a83990c8d1c013c68f61d9d51
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Avoid unexpected scrolling
    
    Mentioned in #169.
    
    * Comment out the use of diff-hl-inline-popup--ensure-enough-lines: it 
caused the problem.
    * Have diff-hl-show-hunk--goto-hunk-overlay also redisplay if point moved 
down.
    * Delete unused function.
---
 diff-hl-inline-popup.el |  6 +-----
 diff-hl-show-hunk.el    | 13 +++++++++----
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/diff-hl-inline-popup.el b/diff-hl-inline-popup.el
index e94c0c7..3e9f417 100644
--- a/diff-hl-inline-popup.el
+++ b/diff-hl-inline-popup.el
@@ -52,10 +52,6 @@
    (nthcdr offset list)
    (- (length list) length offset)))
 
-(defun diff-hl-inline-popup--first-visible-line-in-window ()
-  "Return first visible line in current window."
-  (line-number-at-pos (window-start)))
-
 (defun diff-hl-inline-popup--ensure-enough-lines (pos content-height)
   "Ensure there is enough lines below POS to show the inline popup with 
CONTENT-HEIGHT height."
   (let* ((line (line-number-at-pos pos))
@@ -268,7 +264,7 @@ is closed."
     (setq diff-hl-inline-popup--height 
(diff-hl-inline-popup--compute-content-height height))
     (setq diff-hl-inline-popup--height (min diff-hl-inline-popup--height
                                             (length 
diff-hl-inline-popup--current-lines)))
-    (diff-hl-inline-popup--ensure-enough-lines point 
diff-hl-inline-popup--height)
+    ;; (diff-hl-inline-popup--ensure-enough-lines point 
diff-hl-inline-popup--height)
     (diff-hl-inline-popup-transient-mode 1)
     (diff-hl-inline-popup-scroll-to 0)
     overlay))
diff --git a/diff-hl-show-hunk.el b/diff-hl-show-hunk.el
index d9b76ac..c1b2013 100644
--- a/diff-hl-show-hunk.el
+++ b/diff-hl-show-hunk.el
@@ -264,6 +264,7 @@ BUFFER is a buffer with the hunk."
                   (overlay-put invisible-overlay 'invisible nil)
                   (delete-overlay invisible-overlay)
                   (diff-hl-inline-popup-hide)))))
+      (diff-hl-show-hunk--goto-hunk-overlay overlay)
       (let ((height
              (when smart-lines
                (when (not (eq 0 original-lines-number))
@@ -278,7 +279,7 @@ BUFFER is a buffer with the hunk."
          #'diff-hl-show-hunk-hide
          point
          height))
-      (diff-hl-show-hunk--goto-hunk-overlay overlay))))
+      )))
 
 (defun diff-hl-show-hunk-copy-original-text ()
   "Extracts all the lines from BUFFER starting with '-' to the kill ring."
@@ -317,9 +318,13 @@ of `diff-hl-show-hunk'."
   "Tries to display the whole overlay, and place the point at the
 end of the OVERLAY, so posframe/inline is placed below the hunk."
   (when (and (overlayp overlay) (overlay-buffer overlay))
-    (goto-char (overlay-start overlay))
-    (when (< (point) (window-start))
-      (set-window-start nil (point)))
+    (let ((pt (point)))
+      (goto-char (overlay-start overlay))
+      (cond
+       ((< (point) (window-start))
+        (set-window-start nil (point)))
+       ((> (point) pt)
+        (redisplay))))
     (goto-char (1- (overlay-end overlay)))))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]