]> code.delx.au - gnu-emacs-elpa/commitdiff
ivy: enlarge the minibuffer window if the candiate list doesn't fit
authorFelix Lange <fjl@twurst.com>
Tue, 18 Aug 2015 09:16:44 +0000 (11:16 +0200)
committerFelix Lange <fjl@twurst.com>
Tue, 18 Aug 2015 09:16:44 +0000 (11:16 +0200)
Fixes #161
Fixes #198

ivy.el

diff --git a/ivy.el b/ivy.el
index 37091f0576b83737cea5ede8f3329db12e000a90..48f3e1214c6e00226496fc7fca3f0777dff31e61 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1215,7 +1215,6 @@ Insert .* between each char."
   (set (make-local-variable 'minibuffer-default-add-function)
        (lambda ()
          (list ivy--default)))
-  (setq line-spacing 0)
   (setq-local max-mini-window-height ivy-height)
   (add-hook 'post-command-hook #'ivy--exhibit nil t)
   ;; show completions with empty input
@@ -1377,7 +1376,18 @@ Should be run via minibuffer `post-command-hook'."
       (let ((buffer-undo-list t))
         (save-excursion
           (forward-line 1)
-          (insert text))))))
+          (insert text))))
+    (when (display-graphic-p)
+      (ivy--resize-minibuffer-to-fit))))
+
+(defun ivy--resize-minibuffer-to-fit ()
+  "Resize the minibuffer window so it has enough space to display
+all of the text contained in the minibuffer."
+  (with-selected-window (minibuffer-window)
+    (let ((text-height (cdr (window-text-pixel-size)))
+          (body-height (window-body-height nil t)))
+      (when (> text-height body-height)
+        (window-resize nil (- text-height body-height) nil t t)))))
 
 (declare-function colir-blend-face-background "ext:colir")