Subject: Re: bug#75765: 30.0.92; which-key-setup-side-window-right causes which-key to fail

From: Robert Pluim <[email-masked]>
Date: Wed, 22 Jan 2025 18:42:53 +0100

>>>>> On Wed, 22 Jan 2025 14:23:31 +0000, Reindert-Jan Ekker <[email-masked]> said:

    Reindert-Jan> Run the following:
    Reindert-Jan> (which-key-mode 1)
    Reindert-Jan> (which-key-setup-side-window-right)

    Reindert-Jan> Then press a key that would show a which-key overview (like M-s or
    Reindert-Jan> M-g). This causes the error:

    Reindert-Jan> Error running timer ‘which-key--update’: (wrong-type-argument wholenump
    Reindert-Jan> -15)

    Reindert-Jan> This error sometimes seems to go away, so on later key presses which-key
    Reindert-Jan> may or may not work.

`which-key--pad-column' is not accounting for the case where the
length of the string itʼs padding is greater than the number of
available columns. This fixes it for me:

Robert
-- 

diff --git a/lisp/which-key.el b/lisp/which-key.el
index 45a02955e11..bfeb9da7422 100644
--- a/lisp/which-key.el
+++ b/lisp/which-key.el
@@ -2038,7 +2038,7 @@ which-key--pad-column
           (mapcar (pcase-lambda (`(,key ,sep ,desc ,_doc))
                     (concat
                      (format col-format key sep desc)
-                     (make-string (- col-desc-width (string-width desc)) ?\s)))
+                     (make-string (max (- col-desc-width (string-width desc)) 0) ?\s)))
                   col-keys))))
 
 (defun which-key--partition-list (n list)