On 2013-02-22 Friday at 23:21 +0800 Nazri Ramliy wrote:
> On Fri, Feb 22, 2013 at 10:00 PM, Roland Eggner
> <[email protected]> wrote:
> > 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.
> 
> A shorter patch, but the fixes the same problem:

Problem fixing confirmed.  That much shorter is really nice.  Combined it with 
another code shortening and added a comment, new patch attached.

-- 
Regards
Roland Eggner

src/version.c |  13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/version.c b/src/version.c
--- a/src/version.c
+++ b/src/version.c
@@ -2486,22 +2486,18 @@ 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;
-
            msg_puts((char_u *)features[idx]);
            if (last_col)
            {
@@ -2515,7 +2511,10 @@ list_features()
            }
        }
        else
-           msg_putchar('\n');
+       {
+           if (msg_col > 0)
+               msg_putchar('\n');
+       }
     }
 }
     void

Attachment: pgp1M86DIpw2p.pgp
Description: PGP signature

Raspunde prin e-mail lui