=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/menu.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- src/usr.bin/tmux/menu.c 2021/10/22 17:12:50 1.40 +++ src/usr.bin/tmux/menu.c 2021/11/11 09:22:33 1.41 @@ -1,4 +1,4 @@ -/* $OpenBSD: menu.c,v 1.40 2021/10/22 17:12:50 nicm Exp $ */ +/* $OpenBSD: menu.c,v 1.41 2021/11/11 09:22:33 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott @@ -89,22 +89,26 @@ keylen = strlen(key) + 3; /* 3 = space and two brackets */ /* - * Only add the key if there is space for the entire item text - * and the key. + * Add the key if it is shorter than a quarter of the available + * space or there is space for the entire item text and the + * key. */ - if (keylen >= max_width || slen >= max_width - keylen) + if (keylen <= max_width / 4) + max_width -= keylen; + else if (keylen >= max_width || slen >= max_width - keylen) key = NULL; } + if (slen > max_width) { + max_width--; + suffix = ">"; + } if (key != NULL) - xasprintf(&name, "%s#[default] #[align=right](%s)", s, key); - else { - if (slen > max_width) { - max_width--; - suffix = ">"; - } + xasprintf(&name, "%.*s%s#[default] #[align=right](%s)", + (int)max_width, s, suffix, key); + else xasprintf(&name, "%.*s%s", (int)max_width, s, suffix); - } + new_item->name = name; free(s);