]> code.delx.au - gnu-emacs-elpa/commitdiff
Use window-screen-lines when available
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 6 Aug 2014 04:35:00 +0000 (08:35 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 6 Aug 2014 04:35:00 +0000 (08:35 +0400)
Fixes #160

NEWS.md
company.el

diff --git a/NEWS.md b/NEWS.md
index 33e1e689811e87c02e3cf28580824922f615e5dc..e2a5c484d44395da8b9c590fa44a60a6ee6263f4 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
 
 # Next
 
+* On Emacs 24.4 or newer, tooltip positioning takes line-spacing into account.
 * New face `company-tooltip-search`, used for the search string in the tooltip.
 * The default value of `company-dabbrev-minimum-length` is set to 4, independent
   of what `company-minimum-prefix-length` is set to.
index 7d5ec8cad41d247b1a4cd6e65c8e0a2fbce10ec3..4b5965587d850e2465147ce19d74c11e3d502ce8 100644 (file)
@@ -2363,6 +2363,11 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 
 ;; show
 
+(defsubst company--window-height ()
+  (if (fboundp 'window-screen-lines)
+      (floor (window-screen-lines))
+    (window-body-height)))
+
 (defsubst company--window-width ()
   (let ((ww (window-body-width)))
     ;; Account for the line continuation column.
@@ -2382,7 +2387,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
   "Calculate the appropriate tooltip height.
 Returns a negative number if the tooltip should be displayed above point."
   (let* ((lines (company--row))
-         (below (- (window-body-height) 1 lines)))
+         (below (- (company--window-height) 1 lines)))
     (if (and (< below (min company-tooltip-minimum company-candidates-length))
              (> lines below))
         (- (max 3 (min company-tooltip-limit lines)))