From 308cf47d1533234b9fe2261a60e90048802ced53 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 6 Aug 2014 08:35:00 +0400 Subject: [PATCH] Use window-screen-lines when available Fixes #160 --- NEWS.md | 1 + company.el | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 33e1e6898..e2a5c484d 100644 --- 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. diff --git a/company.el b/company.el index 7d5ec8cad..4b5965587 100644 --- a/company.el +++ b/company.el @@ -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))) -- 2.39.2