[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/which-key 254d6fdc2b 03/11: Don't pad beyond maximal wi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/which-key 254d6fdc2b 03/11: Don't pad beyond maximal width |
Date: |
Thu, 11 Aug 2022 12:58:11 -0400 (EDT) |
branch: externals/which-key
commit 254d6fdc2b3c993b599fc3ca29cda14bc6c0a5fb
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Don't pad beyond maximal width
The old implementation behaved as if the "description" is the only
information that is being displayed, however in actuality the
available width has to be shared with the key (and the separator
between the two).
Failing to take that into account meant that every binding whose
description isn't *by itself* wider than the width available to
display all the information got excessive padding, which later has to
be removed during truncation again (resulting in misleading ellipses).
---
which-key.el | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/which-key.el b/which-key.el
index 89bdbe8645..8162d207f7 100644
--- a/which-key.el
+++ b/which-key.el
@@ -1865,15 +1865,18 @@ element in each list element of KEYS."
(lambda (x y) (max x (which-key--string-width (nth index y))))
keys :initial-value (if initial-value initial-value 0)))
-(defun which-key--pad-column (col-keys)
+(defun which-key--pad-column (col-keys avl-width)
"Take a column of (key separator description) COL-KEYS,
calculate the max width in the column and pad all cells out to
that width."
(let* ((col-key-width (+ which-key-add-column-padding
(which-key--max-len col-keys 0)))
(col-sep-width (which-key--max-len col-keys 1))
- (col-desc-width (which-key--max-len
- col-keys 2 which-key-min-column-description-width))
+ (avl-width (- avl-width col-key-width col-sep-width))
+ (col-desc-width (min avl-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-format (concat "%" (int-to-string col-key-width)
"s%s%-" (int-to-string col-desc-width) "s")))
@@ -1893,8 +1896,8 @@ that width."
"Convert list of KEYS to columns based on dimensions AVL-LINES and AVL-WIDTH.
Returns a `which-key--pages' object that holds the page strings,
as well as metadata."
- (let ((cols-w-widths (mapcar #'which-key--pad-column
- (which-key--partition-list avl-lines keys)))
+ (let ((cols-w-widths (mapcar (lambda (c) (which-key--pad-column c avl-width))
+ (which-key--partition-list avl-lines keys)))
(page-width 0) (n-pages 0) (n-keys 0) (n-columns 0)
page-cols pages page-widths keys/page col)
(if (> (apply #'max (mapcar #'car cols-w-widths)) avl-width)
- [elpa] externals/which-key updated (23fc54eb80 -> 8093644032), ELPA Syncer, 2022/08/11
- [elpa] externals/which-key 783d6954bc 07/11: Support different types for which-key-max-description-length, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key 08d57febc4 08/11: Don't make description longer than allowed when truncating, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key 245be33189 05/11: Fix vertical off-by-one error, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key e993113868 09/11: Allow truncating without using any ellipsis, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key fe68fe2812 06/11: Avoid unnecessary work, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key 16c992f80f 02/11: Displaying just one column means pages are arranged vertically, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key 2875fcdc93 10/11: Ignore .DS_Store, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key d924a4a766 01/11: Calculate format string only once, ELPA Syncer, 2022/08/11
- [elpa] externals/which-key 254d6fdc2b 03/11: Don't pad beyond maximal width,
ELPA Syncer <=
- [elpa] externals/which-key 8093644032 11/11: Merge commit 'pullreqs/343', ELPA Syncer, 2022/08/11
- [elpa] externals/which-key 5fe2d3317d 04/11: Fix horizontal off-by-one error, ELPA Syncer, 2022/08/11