about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2002-05-23 12:15:03 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2002-05-23 12:15:03 +0000
commitd786ca4438883723569bf72a0fe43b2306915838 (patch)
tree61e8e1ee6923bea1e1d399350ac6a0d65a8529e0
parentc08e0636e84dbf19b061748a466c59d5061824f7 (diff)
downloadzsh-d786ca4438883723569bf72a0fe43b2306915838.tar.gz
zsh-d786ca4438883723569bf72a0fe43b2306915838.tar.xz
zsh-d786ca4438883723569bf72a0fe43b2306915838.zip
allow multiple lines in option completion lists to share the same description, for (hopefully) cleaner displays (17212)
-rw-r--r--ChangeLog6
-rw-r--r--Src/Zle/computil.c23
2 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 41612071d..ed0a59c64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-05-23  Sven Wischnowsky  <wischnow@zsh.org>
+
+	* 17212: Src/Zle/computil.c: allow multiple lines in option
+	completion lists to share the same description, for (hopefully)
+	cleaner displays
+
 2002-05-23  Clint Adams  <clint@zsh.org>
 
 	* Matt Zimmerman: 17211: Completion/Unix/Command/_cvs:
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 372e553d2..7254db531 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -260,8 +260,6 @@ cd_prep()
                 *strp++ = gs;
             }
 
-        qsort(grps, lines, sizeof(Cdstr), cd_sort);
-
         cd_state.gpre = 0;
         for (i = 0; i < cd_state.maxg; i++)
             cd_state.gpre += wids[i] + 2;
@@ -269,6 +267,23 @@ cd_prep()
         if (cd_state.gpre > cd_state.maxmlen && cd_state.maxglen > 1)
             return 1;
 
+        qsort(grps, lines, sizeof(Cdstr), cd_sort);
+
+        for (i = lines, strp = grps; i > 1; i--, strp++) {
+            strp2 = strp + 1;
+            if (!strcmp((*strp)->desc, (*strp2)->desc))
+                continue;
+            for (j = i - 2, strp2++; j > 0; j--, strp2++)
+                if (!strcmp((*strp)->desc, (*strp2)->desc)) {
+                    Cdstr tmp = *strp2;
+
+                    memmove(strp + 2, strp + 1,
+                            (strp2 - strp - 1) * sizeof(Cdstr));
+
+                    *++strp = tmp;
+                    i--;
+                }
+        }
         expl =  (Cdrun) zalloc(sizeof(*run));
         expl->type = CRT_EXPL;
         expl->strs = grps[0];
@@ -666,6 +681,10 @@ cd_get(char **params)
                 dpys = (char **) zalloc((i + 1) * sizeof(char *));
 
                 for (dp = dpys, str = run->strs; str; str = str->run) {
+                    if (str->run && !strcmp(str->desc, str->run->desc)) {
+                        *dp++ = ztrdup("");
+                        continue;
+                    }
                     memset(dbuf + cd_state.slen, ' ', dlen - 1);
                     dbuf[dlen + cd_state.slen - 1] = '\0';
                     strcpy(dbuf, cd_state.sep);