From 43b2cbb1972bc6f2261697df0f35a1aee8f1d835 Mon Sep 17 00:00:00 2001 From: Clemens Radermacher Date: Thu, 11 Feb 2021 22:49:05 +0100 Subject: [PATCH 1/4] Take line spacing into account for fixed vertical window heights --- selectrum.el | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/selectrum.el b/selectrum.el index 3f0e32ba..7c22f0e8 100644 --- a/selectrum.el +++ b/selectrum.el @@ -1296,20 +1296,22 @@ window is supposed to be shown vertically." selectrum-fix-vertical-window-height) vertical) (let* ((max (selectrum--max-window-height)) - (height (if selectrum-display-action - max - ;; Add one for prompt. - (1+ max)))) - (set-window-text-height window height))) + (lines (if selectrum-display-action + max + ;; Add one for prompt. + (1+ max))) + ;; Include possible line spacing. + (height (* lines (line-pixel-height)))) + (selectrum--set-window-height window height))) (t (when-let ((expand (selectrum--expand-window-for-content-p window))) (cond (selectrum-display-action - (selectrum--update-display-window-height window)) + (selectrum--fit-window-to-buffer window)) (t - (selectrum--update-minibuffer-height window))))))) + (selectrum--set-window-height window))))))) -(defun selectrum--update-display-window-height (window) - "Update window height of WINDOW. +(defun selectrum--fit-window-to-buffer (window) + "Fit window height to its buffer contents. Also works for frames if WINDOW is the root window of its frame." (let ((window-resize-pixelwise t) (window-size-fixed nil) @@ -1317,10 +1319,11 @@ Also works for frames if WINDOW is the root window of its frame." (fit-window-to-buffer-horizontally nil)) (fit-window-to-buffer window nil 1))) -(defun selectrum--update-minibuffer-height (window) - "Update window height of minibuffer WINDOW. -WINDOW will be updated to fit its content vertically." - (let ((dheight (cdr (window-text-pixel-size window))) +(defun selectrum--set-window-height (window &optional height) + "Set window height of WINDOW to HEIGHT pixel. +If HEIGHT is not given WINDOW will be updated to fit its content +vertically." + (let ((dheight (or height (cdr (window-text-pixel-size window)))) (wheight (window-pixel-height window)) (window-resize-pixelwise t)) (window-resize From e81551239d56c5938ef147f594226498909f1600 Mon Sep 17 00:00:00 2001 From: Clemens Radermacher Date: Thu, 11 Feb 2021 23:00:19 +0100 Subject: [PATCH 2/4] Add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75eac766..77933fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ The format is based on [Keep a Changelog]. canonical representation of a candidate has been removed ([#403]). ### Features +* Line spacing is taken into account when using fixed window heights + ([#424], [#432]). * The new option `selectrum-max-window-height` can now be used to configure the maximal display window height analogue to the built-in `max-mini-window-height`. The new option replaces the usage of the @@ -368,11 +370,13 @@ The format is based on [Keep a Changelog]. [#413]: https://github.com/raxod502/selectrum/pull/413 [#414]: https://github.com/raxod502/selectrum/pull/414 [#420]: https://github.com/raxod502/selectrum/issues/420 +[#424]: https://github.com/raxod502/selectrum/issues/424 [#425]: https://github.com/raxod502/selectrum/issues/425 [#421]: https://github.com/raxod502/selectrum/pull/421 [#427]: https://github.com/raxod502/selectrum/issues/427 [#430]: https://github.com/raxod502/selectrum/pull/430 [#431]: https://github.com/raxod502/selectrum/pull/431 +[#432]: https://github.com/raxod502/selectrum/pull/432 ## 3.0 (released 2020-10-20) ### Breaking changes From 7b35878839986eb42e3a0fe619c4ad76949300e1 Mon Sep 17 00:00:00 2001 From: Clemens Radermacher Date: Thu, 11 Feb 2021 23:01:40 +0100 Subject: [PATCH 3/4] Remove deprecated selectrum-fix-minibuffer-height --- selectrum.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/selectrum.el b/selectrum.el index 7c22f0e8..c1fcaf81 100644 --- a/selectrum.el +++ b/selectrum.el @@ -1292,9 +1292,7 @@ window is supposed to be shown vertically." (and (window-at-side-p window 'bottom) (not (window-at-side-p window 'top)))) (set-window-text-height window 1))) - ((and (or (bound-and-true-p selectrum-fix-minibuffer-height) - selectrum-fix-vertical-window-height) - vertical) + ((and vertical selectrum-fix-vertical-window-height) (let* ((max (selectrum--max-window-height)) (lines (if selectrum-display-action max From be07638b4bfb79c07f0d09f9aefce647c7f4909d Mon Sep 17 00:00:00 2001 From: Clemens Radermacher Date: Thu, 11 Feb 2021 23:06:31 +0100 Subject: [PATCH 4/4] Fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77933fe4..eedad6e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ The format is based on [Keep a Changelog]. canonical representation of a candidate has been removed ([#403]). ### Features -* Line spacing is taken into account when using fixed window heights +* Line spacing is taken into account when using a fixed window height ([#424], [#432]). * The new option `selectrum-max-window-height` can now be used to configure the maximal display window height analogue to the built-in