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

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

[elpa] master dd3e1c9 038/184: swiper.el (swiper--maybe-recenter): Refac


From: Oleh Krehel
Subject: [elpa] master dd3e1c9 038/184: swiper.el (swiper--maybe-recenter): Refactor
Date: Wed, 16 Oct 2019 13:14:44 -0400 (EDT)

branch: master
commit dd3e1c9ea68db178e0a09254d4e8bd2d94115699
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper--maybe-recenter): Refactor
---
 swiper.el | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/swiper.el b/swiper.el
index b2c884b..0ba5adc 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1036,9 +1036,14 @@ WND, when specified is the window."
 (defun swiper--maybe-recenter ()
   (cond (swiper-action-recenter
          (recenter))
-        ((and swiper--current-window-start
-              (swiper--recenter-p))
-         (set-window-start (selected-window) swiper--current-window-start))))
+        ((swiper--recenter-p)
+         (when swiper--current-window-start
+           (set-window-start (selected-window) swiper--current-window-start))
+         (when (or
+                (< (point) (window-start))
+                (> (point) (window-end (ivy-state-window ivy-last) t)))
+           (recenter))))
+  (setq swiper--current-window-start (window-start)))
 
 (defun swiper--action (x)
   "Goto line X."
@@ -1408,7 +1413,7 @@ that we search only for one character."
           (and (> (length x) 0)
                (setq x (get-text-property 0 'point x))))
       (with-ivy-window
-          (goto-char x)
+        (goto-char x)
         (when (and (or (eq this-command 'ivy-previous-line-or-history)
                        (and (eq this-command 'ivy-done)
                             (eq last-command 'ivy-previous-line-or-history)))
@@ -1416,18 +1421,12 @@ that we search only for one character."
           (goto-char (match-beginning 0)))
         (isearch-range-invisible (point) (1+ (point)))
         (swiper--maybe-recenter)
-        (when (and (swiper--recenter-p)
-                   (or
-                    (< (point) (window-start))
-                    (> (point) (window-end (ivy-state-window ivy-last) t))))
-          (recenter))
-        (setq swiper--current-window-start (window-start))
         (unless (eq ivy-exit 'done)
           (swiper--cleanup)
           (swiper--delayed-add-overlays)
           (swiper--add-cursor-overlay
            (ivy-state-window ivy-last))))
-      (swiper--cleanup)))
+    (swiper--cleanup)))
 
 (defun swiper-isearch-thing-at-point ()
   "Insert `symbol-at-point' into the minibuffer of `swiper-isearch'.



reply via email to

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