]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix the minibuffer being too small with enough candidates
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 15 Jun 2015 13:30:47 +0000 (15:30 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 15 Jun 2015 13:30:47 +0000 (15:30 +0200)
* ivy.el (ivy--format): Fix the bug of getting the minibuffer height
  less than `ivy-height' when `ivy--index' was between `ivy--length'
  and (- ivy--length (/ ivy--height 2)).

* ivy-test.el (ivy--format): Add test.

ivy-test.el
ivy.el

index 1062cd83310a34461896fa155e6896fc5335b727..af0fc60b95fba572227fccbf66123cb183f19d6f 100644 (file)
                    "^"))
   (should (string= (ivy--regex-fuzzy "$")
                    "$")))
+
+(ert-deftest ivy--format ()
+  (should (string= (let ((ivy--index 10)
+                         (ivy-format-function (lambda (x) (mapconcat #'identity x "\n")))
+                         (cands '("NAME"
+                                  "SYNOPSIS"
+                                  "DESCRIPTION"
+                                  "FUNCTION LETTERS"
+                                  "SWITCHES"
+                                  "DIAGNOSTICS"
+                                  "EXAMPLE 1"
+                                  "EXAMPLE 2"
+                                  "EXAMPLE 3"
+                                  "SEE ALSO"
+                                  "AUTHOR")))
+                     (ivy--format cands))
+                   #("\nDESCRIPTION\nFUNCTION LETTERS\nSWITCHES\nDIAGNOSTICS\nEXAMPLE 1\nEXAMPLE 2\nEXAMPLE 3\nSEE ALSO\nAUTHOR"
+                     0 90 (read-only nil)
+                     90 96 (face ivy-current-match read-only nil)))))
diff --git a/ivy.el b/ivy.el
index c81246644ff89ec3717e2f58cc9176847d65017f..744abc73b0d7ca2e26491f84afac7b100d42fffb 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1233,8 +1233,9 @@ CANDS is a list of strings."
     (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)))))
            (cands (cl-subseq cands start end))
-           (index (min ivy--index half-height (1- (length cands)))))
+           (index (- ivy--index start)))
       (when ivy--directory
         (setq cands (mapcar (lambda (x)
                               (if (string-match-p "/\\'" x)