On 2013-02-20 Wednesday at 16:48 +0100 Bram Moolenaar wrote:
> 
> Patch 7.3.826
> Problem:    List of features in :version output is hard to read.
> Solution:   Make columns. (Nazri Ramliy)
> Files:            src/version.c

On wide terminals the feature list in :version message is interrupted by empty 
lines, observed with e.g. COLUMNS=320.  Bugfix attached.

-- 
Regards
Roland Eggner

src/version.c |  26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/version.c b/src/version.c
--- a/src/version.c
+++ b/src/version.c
@@ -2461,6 +2461,7 @@ list_features()
     int                nrow;
     int                nfeat = 0;
     int                width = 0;
+    int                nlwritten;
 
     /* Find the length of the longest feature name, use that + 1 as the column
      * width */
@@ -2486,27 +2487,30 @@ list_features()
        return;
     }
 
-    ncol = (int) Columns / width;
     /* The rightmost column doesn't need a separator.
      * Sacrifice it to fit in one more column if possible. */
-    if (Columns % width == width - 1)
-       ncol++;
-
+    ncol = (int) (Columns + 1) / width;
     nrow = nfeat / ncol + (nfeat % ncol ? 1 : 0);
 
+    /* i counts columns then rows.  idx counts rows then columns. */
     for (i = 0; !got_int && i < nrow * ncol; ++i)
     {
        int idx = (i / ncol) + (i % ncol) * nrow;
-
        if (idx < nfeat)
        {
            int last_col = (i + 1) % ncol == 0;
-
+           /* If Columns > some 180, then ncols > nrows, leading to the 
possibility
+            * of >=1 rightmost columns of our ncols*nrows-sized table beeing 
empty.
+            * In this case, nlwritten avoids output of empty lines. */
+           nlwritten = 0;
            msg_puts((char_u *)features[idx]);
            if (last_col)
            {
-               if (msg_col > 0)
+               if (msg_col > 0 && !nlwritten)
+               {
                    msg_putchar('\n');
+                   nlwritten = 1;
+               }
            }
            else
            {
@@ -2515,7 +2519,13 @@ list_features()
            }
        }
        else
-           msg_putchar('\n');
+       {
+           if(!nlwritten)
+           {
+               msg_putchar('\n');
+               nlwritten = 1;
+           }
+       }
     }
 }
     void

Attachment: pgpTU2RzSmuBI.pgp
Description: PGP signature

Raspunde prin e-mail lui