* 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.
"^"))
(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)))))
(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)