From 844e569b632fc032576edc039f793be47fde724e Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Wed, 18 Sep 2013 23:50:04 +0200 Subject: 31735: fix off-by-one in completion utility cache code. Was causing crashes in complex completions, particularly with taskwarrior --- Src/Zle/computil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Src/Zle/computil.c') diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index cd508d0ac..2c323eefe 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -2992,7 +2992,7 @@ get_cvdef(char *nam, char **args) return *p; } else if (!min || !*p || (*p)->lastt < (*min)->lastt) min = p; - if (i) + if (i > 0) min = p; if ((new = parse_cvdef(nam, args))) { freecvdef(*min); -- cgit v1.2.3 From 61deff76f22310ce9e10dd2174b8cf8e48c678ee Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Thu, 19 Sep 2013 07:55:53 -0700 Subject: 31737: same loop counter fix in get_cadef as get_cvdef. --- ChangeLog | 4 ++++ Src/Zle/computil.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Src/Zle/computil.c') diff --git a/ChangeLog b/ChangeLog index 12b5b5b0c..6256f5210 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-09-19 Barton E. Schaefer + + * 31737: Src/Zle/computil.c (get_cadef): same fix as get_cvdef. + 2013-09-19 Peter Stephenson * Axel Beckert: 31735: Src/Zle/computil.c (get_cvdef): diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 2c323eefe..f8983c3ff 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -1608,7 +1608,7 @@ get_cadef(char *nam, char **args) return *p; } else if (!min || !*p || (*p)->lastt < (*min)->lastt) min = p; - if (i) + if (i > 0) min = p; if ((new = parse_cadef(nam, args))) { freecadef(*min); -- cgit v1.2.3 From ea30fdaf25ad11ca727d3708bdd47b0f90d9ff68 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Thu, 3 Oct 2013 14:52:54 -0700 Subject: 31781: "compdescribe -i" clears the completion list column padding width --- ChangeLog | 6 ++++++ Src/Zle/computil.c | 1 + 2 files changed, 7 insertions(+) (limited to 'Src/Zle/computil.c') diff --git a/ChangeLog b/ChangeLog index 2c50b3228..9ec3bc581 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-10-03 Barton E. Schaefer + + * 31781: Src/Zle/computil.c: "compdescribe -i" must clear the + completion list column padding width along with the rest of the + description state. Cf. 31782. + 2013-09-26 Barton E. Schaefer * 31772: Src/params.c: queue_signals() to prevent re-entry into diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index f8983c3ff..ee3918566 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -465,6 +465,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep, cd_state.showd = disp; cd_state.maxg = cd_state.groups = cd_state.descs = 0; cd_state.maxmlen = atoi(mlen); + cd_state.premaxw = 0; itmp = zterm_columns - cd_state.swidth - 4; if (cd_state.maxmlen > itmp) cd_state.maxmlen = itmp; -- cgit v1.2.3 From 75fdec17b1ed7e4b3ede4b995003175b885d5f6d Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Thu, 3 Oct 2013 15:59:52 -0700 Subject: 31784: better line width calculation for completion listings When deciding whether there is enough horizontal space to show completion descriptions for each match in a listing, treat the separator as part of the description rather than as part of the match, and account for lines that have already wrapped due to very long matches. --- ChangeLog | 6 ++++++ Src/Zle/computil.c | 58 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 25 deletions(-) (limited to 'Src/Zle/computil.c') diff --git a/ChangeLog b/ChangeLog index 9ec3bc581..bd37e0a2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2013-10-03 Barton E. Schaefer + * 31784: Src/Zle/computil.c: when deciding whether there is enough + horizontal space to show completion descriptions for each match in + a listing, treat the separator as part of the description rather + than as part of the match, and account for lines that have already + wrapped due to very long matches. + * 31781: Src/Zle/computil.c: "compdescribe -i" must clear the completion list column padding width along with the rest of the description state. Cf. 31782. diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index ee3918566..f5e6ba195 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -644,35 +644,43 @@ cd_get(char **params) p += str->len; memset(p, ' ', (l = (cd_state.premaxw - str->width + CM_SPACE))); p += l; - strcpy(p, cd_state.sep); - p += cd_state.slen; - /* - * copy a character at once until no more screen width - * is available. Leave 1 character at the end of screen - * as safety margin - */ remw = zterm_columns - cd_state.premaxw - cd_state.swidth - 3; - d = str->desc; - w = MB_METASTRWIDTH(d); - if (w <= remw) - strcpy(p, d); - else { - pp = p; - while (remw > 0 && *d) { - l = MB_METACHARLEN(d); - memcpy(pp, d, l); - pp[l] = '\0'; - w = MB_METASTRWIDTH(pp); - if (w > remw) { - *pp = '\0'; - break; - } + while (remw < 0 && zterm_columns) { + /* line wrapped, use remainder of the extra line */ + remw += zterm_columns; + } + if (cd_state.slen < remw) { + strcpy(p, cd_state.sep); + p += cd_state.slen; + remw -= cd_state.slen; - pp += l; - d += l; - remw -= w; + /* + * copy a character at once until no more screen + * width is available. Leave 1 character at the + * end of screen as safety margin + */ + d = str->desc; + w = MB_METASTRWIDTH(d); + if (w <= remw) + strcpy(p, d); + else { + pp = p; + while (remw > 0 && *d) { + l = MB_METACHARLEN(d); + memcpy(pp, d, l); + pp[l] = '\0'; + w = MB_METASTRWIDTH(pp); + if (w > remw) { + *pp = '\0'; + break; + } + + pp += l; + d += l; + remw -= w; + } } } -- cgit v1.2.3