branch: elpa/scroll-on-jump
commit 93dbd780cc84bf87e735744f84be235b4d56df9e
Author: Campbell Barton <ideasma...@gmail.com>
Commit: Campbell Barton <ideasma...@gmail.com>

    Workaround bug in evil visual line mode
    
    Evil visual line mode would scroll back to the original location
    after scrolling completed.
---
 scroll-on-jump.el | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/scroll-on-jump.el b/scroll-on-jump.el
index 8e3c5b4722..7c59dbb292 100644
--- a/scroll-on-jump.el
+++ b/scroll-on-jump.el
@@ -139,6 +139,22 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as 
well."
   "Blend FACTOR between A and B using ease style curvature."
   (+ a (* (- b a) (- (* 3.0 factor factor) (* 2.0 factor factor factor)))))
 
+(defsubst scroll-on-jump--evil-visual-mode-workaround ()
+  "Workaround for `evil-mode' line-mode."
+  ;; Without this, the line mode point jumps back to the origin,
+  ;; the mark needs to be set to the `point'.
+  ;; https://github.com/emacs-evil/evil/issues/1708
+  (when
+    (and
+      (fboundp 'evil-visual-state-p)
+      (funcall 'evil-visual-state-p)
+      (fboundp 'evil-visual-type)
+      (eq (funcall 'evil-visual-type) 'line)
+      (boundp 'evil-visual-point))
+    (let ((mark (symbol-value 'evil-visual-point)))
+      (when (markerp mark)
+        (set-marker mark (point))))))
+
 
 ;; ---------------------------------------------------------------------------
 ;; Internal Logic
@@ -516,7 +532,9 @@ Argument USE-WINDOW-START detects window scrolling when 
non-nil."
               (prog1 (goto-char point-next)
                 (redisplay t)))
             (t
-              (scroll-on-jump-auto-center window point-prev point-next))))))))
+              (scroll-on-jump-auto-center window point-prev point-next)))
+
+          (scroll-on-jump--evil-visual-mode-workaround))))))
 
 
 ;; ---------------------------------------------------------------------------

Reply via email to