emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/which-key 5fe2d3317d 04/11: Fix horizontal off-by-one e


From: ELPA Syncer
Subject: [elpa] externals/which-key 5fe2d3317d 04/11: Fix horizontal off-by-one error
Date: Thu, 11 Aug 2022 12:58:11 -0400 (EDT)

branch: externals/which-key
commit 5fe2d3317d60411970e662d62ffc05fe5eac7319
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Fix horizontal off-by-one error
    
    Delay increasing width used by columns until we know that we have to
    do so because we have determined that there is enough room to add an
    additional column and a space between the last two columns.
    
    If we don't do that, then we can easily get an off-by-one error.  If
    docstrings are shown and the window is narrow, then it is likely that
    we end up using the maximal width.  If we then add one to the actual
    width and later compare that again with the maximal width, then that
    is too width.
---
 which-key.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/which-key.el b/which-key.el
index 8162d207f7..9d5e403f6d 100644
--- a/which-key.el
+++ b/which-key.el
@@ -1877,7 +1877,7 @@ that width."
                              (which-key--max-len
                                col-keys 2
                               which-key-min-column-description-width)))
-         (col-width      (+ 1 col-key-width col-sep-width col-desc-width))
+         (col-width      (+ col-key-width col-sep-width col-desc-width))
         (col-format     (concat "%" (int-to-string col-key-width)
                                  "s%s%-" (int-to-string col-desc-width) "s")))
     (cons col-width
@@ -1915,10 +1915,10 @@ as well as metadata."
         (while (and cols-w-widths
                     (or (null which-key-max-display-columns)
                         (< n-columns which-key-max-display-columns))
-                    (<= (+ (caar cols-w-widths) page-width) avl-width))
+                    (<= (+ page-width 1 (caar cols-w-widths)) avl-width))
           (setq col (pop cols-w-widths))
           (push (cdr col) page-cols)
-          (cl-incf page-width (car col))
+          (cl-incf page-width (1+ (car col)))
           (cl-incf n-keys (length (cdr col)))
           (cl-incf n-columns))
         (push (which-key--join-columns page-cols) pages)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]