2018-02-10 17:37 GMT+03:00 Bram Moolenaar <b...@moolenaar.net>:
>
> Patch 8.0.1491
> Problem:    The minimum width of the popup menu is hard coded.
> Solution:   Add the 'pumwidth' option. (Christian Brabandt, James McCoy,
>             closes #2314)
> Files:      runtime/doc/options.txt, src/option.c, src/option.h,
>             src/popupmnu.c
>
>
> *** ../vim-8.0.1490/runtime/doc/options.txt     2018-02-03 15:14:10.014778315 
> +0100
> --- runtime/doc/options.txt     2018-02-10 14:22:37.338325773 +0100
> ***************
> *** 5851,5856 ****
> --- 5955,5970 ----
>         Insert mode completion.  When zero as much space as available is used.
>         |ins-completion-menu|.
>
> +                                               *'pumwidth'* *'pw'*
> + 'pumwidth' 'pw'               number  (default 0)
> +                       global
> +                       {not available when compiled without the
> +                       |+insert_expand| feature}
> +                       {not in Vi}
> +       Determines the minium width to use for the popup menu for Insert mode
> +       completion.  When zero the default of 15 screen cells is used.

What’s the point of having default zero falling back to default 15 in
place of having default 15 with error when trying to set option to
zero? This makes code which needs to know effective &pumwidth
unnecessary complicated and needing to use magic numbers as 15 is not
exported as any VimL symbol.

> +       |ins-completion-menu|.
> +
>                                                 *'pythondll'*
>   'pythondll'           string  (default depends on the build)
>                         global
> *** ../vim-8.0.1490/src/option.c        2018-02-03 15:14:10.010778342 +0100
> --- src/option.c        2018-02-10 14:19:14.975639938 +0100
> ***************
> *** 2239,2244 ****
> --- 2239,2251 ----
>                             (char_u *)NULL, PV_NONE,
>   #endif
>                             {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
> +     {"pumwidth",    "pw",   P_NUM|P_VI_DEF,
> + #ifdef FEAT_INS_EXPAND
> +                           (char_u *)&p_pw, PV_NONE,
> + #else
> +                           (char_u *)NULL, PV_NONE,
> + #endif
> +                           {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
>       {"pythonthreedll",  NULL,   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
>   #if defined(DYNAMIC_PYTHON3)
>                             (char_u *)&p_py3dll, PV_NONE,
> *** ../vim-8.0.1490/src/option.h        2018-01-31 21:48:25.228668790 +0100
> --- src/option.h        2018-02-10 14:19:14.975639938 +0100
> ***************
> *** 424,429 ****
> --- 424,430 ----
>   #ifdef FEAT_INS_EXPAND
>   EXTERN char_u *p_cot;         /* 'completeopt' */
>   EXTERN long   p_ph;           /* 'pumheight' */
> + EXTERN long   p_pw;           /* 'pumwidth' */
>   #endif
>   EXTERN char_u *p_cpo;         /* 'cpoptions' */
>   #ifdef FEAT_CSCOPE
> *** ../vim-8.0.1490/src/popupmnu.c      2017-11-26 16:53:12.323475402 +0100
> --- src/popupmnu.c      2018-02-10 15:12:14.356780917 +0100
> ***************
> *** 67,72 ****
> --- 67,81 ----
>   }
>
>   /*
> +  * Return the minimum width of the popup menu.
> +  */
> +     static int
> + pum_get_width(void)
> + {
> +     return p_pw == 0 ? PUM_DEF_WIDTH : p_pw;
> + }
> +
> + /*

Also this function would be completely useless if p_pw==0 case did not
exist: could be using p_pw directly instead.

>    * Show the popup menu with items "array[size]".
>    * "array" must remain valid until pum_undisplay() is called!
>    * When possible the leftmost character is aligned with screen column "col".
> ***************
> *** 93,99 ****
>
>       do
>       {
> !       def_width = PUM_DEF_WIDTH;
>         above_row = 0;
>         below_row = cmdline_row;
>
> --- 102,108 ----
>
>       do
>       {
> !       def_width = pum_get_width();
>         above_row = 0;
>         below_row = cmdline_row;
>
> ***************
> *** 216,231 ****
>         if (def_width < max_width)
>             def_width = max_width;
>
> !       if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
>   #ifdef FEAT_RIGHTLEFT
>                     && !curwin->w_p_rl)
> !               || (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width)
>   #endif
>            ))
>         {
>             /* align pum column with "col" */
>             pum_col = col;
>
>   #ifdef FEAT_RIGHTLEFT
>             if (curwin->w_p_rl)
>                 pum_width = pum_col - pum_scrollbar + 1;
> --- 225,241 ----
>         if (def_width < max_width)
>             def_width = max_width;
>
> !       if (((col < Columns - pum_get_width() || col < Columns - max_width)
>   #ifdef FEAT_RIGHTLEFT
>                     && !curwin->w_p_rl)
> !              || (curwin->w_p_rl && (col > pum_get_width() || col > 
> max_width)
>   #endif
>            ))
>         {
>             /* align pum column with "col" */
>             pum_col = col;
>
> +           /* start with the maximum space available */
>   #ifdef FEAT_RIGHTLEFT
>             if (curwin->w_p_rl)
>                 pum_width = pum_col - pum_scrollbar + 1;
> ***************
> *** 234,245 ****
>                 pum_width = Columns - pum_col - pum_scrollbar;
>
>             if (pum_width > max_width + pum_kind_width + pum_extra_width + 1
> !                                                 && pum_width > 
> PUM_DEF_WIDTH)
>             {
>                 pum_width = max_width + pum_kind_width + pum_extra_width + 1;
> !               if (pum_width < PUM_DEF_WIDTH)
> !                   pum_width = PUM_DEF_WIDTH;
>             }
>         }
>         else if (Columns < def_width)
>         {
> --- 244,314 ----
>                 pum_width = Columns - pum_col - pum_scrollbar;
>
>             if (pum_width > max_width + pum_kind_width + pum_extra_width + 1
> !                                               && pum_width > 
> pum_get_width())
>             {
> +               /* the width is too much, make it narrower */
>                 pum_width = max_width + pum_kind_width + pum_extra_width + 1;
> !               if (pum_width < pum_get_width())
> !                   pum_width = pum_get_width();
>             }
> +           else if (((col > pum_get_width() || col > max_width)
> + #ifdef FEAT_RIGHTLEFT
> +                       && !curwin->w_p_rl)
> +               || (curwin->w_p_rl && (col < Columns - pum_get_width()
> +                       || col < Columns - max_width)
> + #endif
> +                   ))
> +           {
> +               /* align right pum edge with "col" */
> + #ifdef FEAT_RIGHTLEFT
> +               if (curwin->w_p_rl)
> +               {
> +                   pum_col = col + max_width + pum_scrollbar + 1;
> +                   if (pum_col >= Columns)
> +                       pum_col = Columns - 1;
> +               }
> +               else
> + #endif
> +               {
> +                   pum_col = col - max_width - pum_scrollbar;
> +                   if (pum_col < 0)
> +                       pum_col = 0;
> +               }
> +
> + #ifdef FEAT_RIGHTLEFT
> +               if (curwin->w_p_rl)
> +                   pum_width = W_ENDCOL(curwin) - pum_col - pum_scrollbar + 
> 1;
> +               else
> + #endif
> +                   pum_width = pum_col - pum_scrollbar;
> +
> +               if (pum_width < pum_get_width())
> +               {
> +                   pum_width = pum_get_width();
> + #ifdef FEAT_RIGHTLEFT
> +                   if (curwin->w_p_rl)
> +                   {
> +                       if (pum_width > pum_col)
> +                           pum_width = pum_col;
> +                   }
> +                   else
> + #endif
> +                   {
> +                       if (pum_width >= Columns - pum_col)
> +                           pum_width = Columns - pum_col - 1;
> +                   }
> +               }
> +               else if (pum_width > max_width + pum_kind_width
> +                                                         + pum_extra_width + 
> 1
> +                           && pum_width > pum_get_width())
> +               {
> +                   pum_width = max_width + pum_kind_width
> +                                                        + pum_extra_width + 
> 1;
> +                   if (pum_width < pum_get_width())
> +                       pum_width = pum_get_width();
> +               }
> +           }
> +
>         }
>         else if (Columns < def_width)
>         {
> ***************
> *** 254,261 ****
>         }
>         else
>         {
> !           if (max_width > PUM_DEF_WIDTH)
> !               max_width = PUM_DEF_WIDTH;      /* truncate */
>   #ifdef FEAT_RIGHTLEFT
>             if (curwin->w_p_rl)
>                 pum_col = max_width - 1;
> --- 323,330 ----
>         }
>         else
>         {
> !           if (max_width > pum_get_width())
> !               max_width = pum_get_width();    /* truncate */
>   #ifdef FEAT_RIGHTLEFT
>             if (curwin->w_p_rl)
>                 pum_col = max_width - 1;
> ***************
> *** 1005,1008 ****
> --- 1074,1078 ----
>         ui_remove_balloon();
>   }
>   # endif
> +
>   #endif
> *** ../vim-8.0.1490/src/version.c       2018-02-10 14:12:39.202145763 +0100
> --- src/version.c       2018-02-10 15:36:04.655222275 +0100
> ***************
> *** 773,774 ****
> --- 773,776 ----
>   {   /* Add new patch number below this line */
> + /**/
> +     1491,
>   /**/
>
> --
> We do not stumble over mountains, but over molehills.
>                                 Confucius
>
>  /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\  an exciting new programming language -- http://www.Zimbu.org        ///
>  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to vim_dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to