summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-09-29 14:11:39 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-10-16 12:40:58 +0000
commita8754b63fc505817a49b4e2de4c3b2f70382a52c (patch)
tree9d661742e53aa7b59a0e34bd8be5879dfc85aa43
parent87965e5e02d7799f8e277b397c95d50aebd2efb5 (diff)
downloadzsh-a8754b63fc505817a49b4e2de4c3b2f70382a52c.tar.gz
zsh-a8754b63fc505817a49b4e2de4c3b2f70382a52c.zip
39500: compdescribe: perform on-screen-width computation using the "nice" length, since the matches are rendered by nice*() functions by compadd
Remove two "###" question comments relative to the patch posted, since the answer to them is (clearly) negative.
-rw-r--r--ChangeLog6
-rw-r--r--Src/Zle/computil.c19
2 files changed, 16 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 97d3bc097..2d638dfdb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-10-16 Daniel Shahaf <d.s@daniel.shahaf.name>
+
+ * 39500: Src/Zle/computil.c: compdescribe: perform
+ on-screen-width computation using the "nice" length, since the
+ matches are rendered by nice*() functions by compadd
+
2016-10-13 Oliver Kiddle <opk@zsh.org>
* 39624: Completion/Unix/Command/_yafc: remove space before
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index cb3c32f1f..0025dc37c 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -199,11 +199,11 @@ cd_calc(void)
set->count++;
if ((l = strlen(str->str)) > cd_state.pre)
cd_state.pre = l;
- if ((l = MB_METASTRWIDTH(str->str)) > cd_state.premaxw)
+ if ((l = ZMB_nicewidth(str->str)) > cd_state.premaxw)
cd_state.premaxw = l;
if (str->desc) {
set->desc++;
- if ((l = strlen(str->desc)) > cd_state.suf)
+ if ((l = strlen(str->desc)) > cd_state.suf) /* ### strlen() assumes no \n */
cd_state.suf = l;
}
}
@@ -490,7 +490,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep,
setp = &(cd_state.sets);
cd_state.sep = ztrdup(sep);
cd_state.slen = strlen(sep);
- cd_state.swidth = MB_METASTRWIDTH(sep);
+ cd_state.swidth = ZMB_nicewidth(sep);
cd_state.sets = NULL;
cd_state.showd = disp;
cd_state.maxg = cd_state.groups = cd_state.descs = 0;
@@ -526,7 +526,8 @@ cd_init(char *nam, char *hide, char *mlen, char *sep,
str->other = NULL;
str->set = set;
- for (tmp = *ap; *tmp && *tmp != ':'; tmp++)
+ /* Advance tmp to the first unescaped colon. */
+ for (tmp = *ap; *tmp && *tmp != ':'; tmp++)
if (*tmp == '\\' && tmp[1])
tmp++;
@@ -537,7 +538,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep,
*tmp = '\0';
str->str = str->match = ztrdup(rembslash(*ap));
str->len = strlen(str->str);
- str->width = MB_METASTRWIDTH(str->str);
+ str->width = ZMB_nicewidth(str->str);
str->sortstr = NULL;
}
if (str)
@@ -692,7 +693,7 @@ cd_get(char **params)
* end of screen as safety margin
*/
d = str->desc;
- w = MB_METASTRWIDTH(d);
+ w = ZMB_nicewidth(d);
if (w <= remw)
strcpy(p, d);
else {
@@ -701,7 +702,7 @@ cd_get(char **params)
l = MB_METACHARLEN(d);
memcpy(pp, d, l);
pp[l] = '\0';
- w = MB_METASTRWIDTH(pp);
+ w = ZMB_nicewidth(pp);
if (w > remw) {
*pp = '\0';
break;
@@ -792,7 +793,7 @@ cd_get(char **params)
cd_state.swidth - CM_SPACE;
p = pp = dbuf + cd_state.slen;
d = str->desc;
- w = MB_METASTRWIDTH(d);
+ w = ZMB_nicewidth(d);
if (w <= remw) {
strcpy(p, d);
remw -= w;
@@ -802,7 +803,7 @@ cd_get(char **params)
l = MB_METACHARLEN(d);
memcpy(pp, d, l);
pp[l] = '\0';
- w = MB_METASTRWIDTH(pp);
+ w = ZMB_nicewidth(pp);
if (w > remw) {
*pp = '\0';
break;