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

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

[elpa] master 9eb5275 227/399: ivy.el (ivy--minibuffer-index-bounds): Ex


From: Oleh Krehel
Subject: [elpa] master 9eb5275 227/399: ivy.el (ivy--minibuffer-index-bounds): Extract
Date: Sat, 20 Jul 2019 14:57:28 -0400 (EDT)

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

    ivy.el (ivy--minibuffer-index-bounds): Extract
---
 ivy.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/ivy.el b/ivy.el
index 2b9b139..658cc50 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3595,6 +3595,14 @@ Note: The usual last two arguments are flipped for 
convenience.")
       (propertize str 'face 'ivy-subdir)
     str))
 
+(defun ivy--minibuffer-index-bounds ()
+  (let* ((half-height (/ ivy-height 2))
+         (start (max 0 (- ivy--index half-height)))
+         (end (min (+ start (1- ivy-height)) ivy--length))
+         (start (max 0 (min start (- end (1- ivy-height))))))
+    (setq ivy--window-index (- ivy--index start))
+    (cons start end)))
+
 (defun ivy--format (cands)
   "Return a string for CANDS suitable for display in the minibuffer.
 CANDS is a list of strings."
@@ -3604,13 +3612,9 @@ CANDS is a list of strings."
   (if (null cands)
       (setf (ivy-state-current ivy-last) "")
     (setf (ivy-state-current ivy-last) (copy-sequence (nth ivy--index cands)))
-    (let* ((half-height (/ ivy-height 2))
-           (start (max 0 (- ivy--index half-height)))
-           (end (min (+ start (1- ivy-height)) ivy--length))
-           (start (max 0 (min start (- end (1- ivy-height)))))
-           (wnd-cands (cl-subseq cands start end))
+    (let* ((bnd (ivy--minibuffer-index-bounds))
+           (wnd-cands (cl-subseq cands (car bnd) (cdr bnd)))
            transformer-fn)
-      (setq ivy--window-index (- ivy--index start))
       (when (setq transformer-fn (ivy-state-display-transformer-fn ivy-last))
         (with-ivy-window
           (with-current-buffer (ivy-state-buffer ivy-last)



reply via email to

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