Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug somewhere in verbose output for completion listing
Already committed 31781. A bit additional:
On Oct 3, 2:32pm, Peter Stephenson wrote:
}
} Complete after wtf2 as far as getting a listing (the separator is the
} default "--" instead of the "#" in the previous posting). This is as
} easy as typing "wtf2 ^D". It already looks a bit screwy at this point
} as the comment is missing even though the separator is present.
The seperator was being inserted into the string before the width was
compared to zterm_columns. Most of the below is just re-indentation,
but because the listing already has to deal with completions so wide
that the line has wrapped, there doesn't seem to be any reason not to
use the space on the last additional line to tack on the description.
What this means is that if you have a long completion match that almost
exactly fills the screen, you'll get all the matches with none of the
descriptions. If the longest matches is a bit less than screen width,
you'll see a truncated description for each match, and if the longest
wraps the screen, you'll see the descriptions again.
Minimizing the number of lines used is the reason for all of this.
Some people might prefer to always see the whole description. At
least this makes it obvious where you'd put a zstyle hook for that.
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index ee39185..f5e6ba1 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;
+ }
}
}
--
Barton E. Schaefer
Messages sorted by:
Reverse Date,
Date,
Thread,
Author