Merge remote-tracking branch 'vim/master'

This commit is contained in:
Kazuki Sakamoto
2018-02-10 09:08:04 -08:00
13 changed files with 259 additions and 24 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
*insert.txt* For Vim version 8.0. Last change: 2018 Jan 26
*insert.txt* For Vim version 8.0. Last change: 2018 Feb 10
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1103,6 +1103,8 @@ items:
item with the same word is already present.
empty when non-zero this match will be added even when it is
an empty string
user_data custom data which is associated with the item and
available in |v:completed_item|
All of these except "icase", "dup" and "empty" must be a string. If an item
does not meet these requirements then an error message is given and further
@@ -1196,6 +1198,8 @@ The menu is used when:
The 'pumheight' option can be used to set a maximum height. The default is to
use all space available.
The 'pumwidth' option can be used to set a minimum width. The default is 15
characters.
There are three states:
1. A complete match has been inserted, e.g., after using CTRL-N or CTRL-P.
+10
View File
@@ -6114,6 +6114,16 @@ A jump table for the options with a short description can be found at |Q_op|.
{not in Vi}
Determines the maximum number of items to show in the popup menu for
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.
|ins-completion-menu|.
*'pythondll'*
+4
View File
@@ -4250,6 +4250,8 @@ ins_compl_add_tv(typval_T *tv, int dir)
(char_u *)"kind", FALSE);
cptext[CPT_INFO] = get_dict_string(tv->vval.v_dict,
(char_u *)"info", FALSE);
cptext[CPT_USER_DATA] = get_dict_string(tv->vval.v_dict,
(char_u *)"user_data", FALSE);
if (get_dict_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL)
icase = get_dict_number(tv->vval.v_dict, (char_u *)"icase");
if (get_dict_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL)
@@ -4772,6 +4774,8 @@ ins_compl_insert(int in_compl_func)
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_KIND]));
dict_add_nr_str(dict, "info", 0L,
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_INFO]));
dict_add_nr_str(dict, "user_data", 0L,
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_USER_DATA]));
}
set_vim_var_dict(VV_COMPLETED_ITEM, dict);
if (!in_compl_func)
+2
View File
@@ -1447,6 +1447,8 @@ f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
/* Skip the first and last item, they are always empty. */
for (i = 1; i < size - 1; ++i)
list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
while (size > 0)
vim_free(array[--size].pum_text);
vim_free(array);
}
}
+4
View File
@@ -1116,6 +1116,10 @@ free_all_mem(void)
spell_free_all();
# endif
#if defined(FEAT_INS_EXPAND) && defined(FEAT_BEVAL_TERM)
ui_remove_balloon();
# endif
# if defined(FEAT_USR_CMDS)
/* Clear user commands (before deleting buffers). */
ex_comclear(NULL);
+7
View File
@@ -2313,6 +2313,13 @@ static struct vimoption options[] =
(char_u *)&p_ph, PV_NONE,
#else
(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,
+1
View File
@@ -424,6 +424,7 @@ EXTERN int p_cp; /* 'compatible' */
#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
+78 -8
View File
@@ -66,6 +66,15 @@ pum_compute_size(void)
}
}
/*
* Return the minimum width of the popup menu.
*/
static int
pum_get_width(void)
{
return p_pw == 0 ? PUM_DEF_WIDTH : p_pw;
}
/*
* Show the popup menu with items "array[size]".
* "array" must remain valid until pum_undisplay() is called!
@@ -93,7 +102,7 @@ pum_display(
do
{
def_width = PUM_DEF_WIDTH;
def_width = pum_get_width();
above_row = 0;
below_row = cmdline_row;
@@ -216,16 +225,17 @@ pum_display(
if (def_width < max_width)
def_width = max_width;
if (((col < Columns - PUM_DEF_WIDTH || col < Columns - 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_DEF_WIDTH || col > max_width)
|| (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,12 +244,71 @@ pum_display(
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 > 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_DEF_WIDTH)
pum_width = PUM_DEF_WIDTH;
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,8 +323,8 @@ pum_display(
}
else
{
if (max_width > PUM_DEF_WIDTH)
max_width = PUM_DEF_WIDTH; /* truncate */
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,4 +1074,5 @@ ui_may_remove_balloon(void)
ui_remove_balloon();
}
# endif
#endif
+4 -1
View File
@@ -34,6 +34,8 @@
byte, thus it can't be above 255.
Must be >= PFD_NOTSPECIAL. */
#define MAXREGIONS 8 /* Number of regions supported. */
/* Type used for indexes in the word tree need to be at least 4 bytes. If int
* is 8 bytes we could use something smaller, but what? */
#if VIM_SIZEOF_INT > 3
@@ -80,7 +82,8 @@ struct slang_S
char_u *sl_info; /* infotext string or NULL */
char_u sl_regions[17]; /* table with up to 8 region names plus NUL */
char_u sl_regions[MAXREGIONS * 2 + 1];
/* table with up to 8 region names plus NUL */
char_u *sl_midword; /* MIDWORD string or NULL */
+10 -9
View File
@@ -54,8 +54,8 @@
* website, etc)
*
* sectionID == SN_REGION: <regionname> ...
* <regionname> 2 bytes Up to 8 region names: ca, au, etc. Lower case.
* First <regionname> is region 1.
* <regionname> 2 bytes Up to MAXREGIONS region names: ca, au, etc. Lower
* case. First <regionname> is region 1.
*
* sectionID == SN_CHARFLAGS: <charflagslen> <charflags>
* <folcharslen> <folchars>
@@ -832,7 +832,7 @@ read_region_section(FILE *fd, slang_T *lp, int len)
{
int i;
if (len > 16)
if (len > MAXREGIONS * 2)
return SP_FORMERROR;
for (i = 0; i < len; ++i)
lp->sl_regions[i] = getc(fd); /* <regionname> */
@@ -1952,8 +1952,9 @@ typedef struct spellinfo_S
char_u *si_info; /* info text chars or NULL */
int si_region_count; /* number of regions supported (1 when there
are no regions) */
char_u si_region_name[17]; /* region names; used only if
* si_region_count > 1) */
char_u si_region_name[MAXREGIONS * 2 + 1];
/* region names; used only if
* si_region_count > 1) */
garray_T si_rep; /* list of fromto_T entries from REP lines */
garray_T si_repsal; /* list of fromto_T entries from REPSAL lines */
@@ -4234,7 +4235,7 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
else
{
line += 8;
if (STRLEN(line) > 16)
if (STRLEN(line) > MAXREGIONS * 2)
smsg((char_u *)_("Too many regions in %s line %d: %s"),
fname, lnum, line);
else
@@ -5954,7 +5955,7 @@ mkspell(
char_u *wfname;
char_u **innames;
int incount;
afffile_T *(afile[8]);
afffile_T *(afile[MAXREGIONS]);
int i;
int len;
stat_T st;
@@ -6025,8 +6026,8 @@ mkspell(
EMSG(_(e_invarg)); /* need at least output and input names */
else if (vim_strchr(gettail(wfname), '_') != NULL)
EMSG(_("E751: Output file name must not have region name"));
else if (incount > 8)
EMSG(_("E754: Only up to 8 regions supported"));
else if (incount > MAXREGIONS)
EMSGN(_("E754: Only up to %ld regions supported"), MAXREGIONS);
else
{
/* Check for overwriting before doing things that may take a lot of
+6 -5
View File
@@ -3259,11 +3259,12 @@ typedef struct
/*
* Array indexes used for cptext argument of ins_compl_add().
*/
#define CPT_ABBR 0 /* "abbr" */
#define CPT_MENU 1 /* "menu" */
#define CPT_KIND 2 /* "kind" */
#define CPT_INFO 3 /* "info" */
#define CPT_COUNT 4 /* Number of entries */
#define CPT_ABBR 0 /* "abbr" */
#define CPT_MENU 1 /* "menu" */
#define CPT_KIND 2 /* "kind" */
#define CPT_INFO 3 /* "info" */
#define CPT_USER_DATA 4 /* "user data" */
#define CPT_COUNT 5 /* Number of entries */
typedef struct {
UINT32_T total[2];
+120
View File
@@ -117,6 +117,126 @@ func Test_omni_dash()
set omnifunc=
endfunc
function! s:CompleteDone_CompleteFuncDict( findstart, base )
if a:findstart
return 0
endif
return {
\ 'words': [
\ {
\ 'word': 'aword',
\ 'abbr': 'wrd',
\ 'menu': 'extra text',
\ 'info': 'words are cool',
\ 'kind': 'W',
\ 'user_data': 'test'
\ }
\ ]
\ }
endfunction
function! s:CompleteDone_CheckCompletedItemDict()
call assert_equal( 'aword', v:completed_item[ 'word' ] )
call assert_equal( 'wrd', v:completed_item[ 'abbr' ] )
call assert_equal( 'extra text', v:completed_item[ 'menu' ] )
call assert_equal( 'words are cool', v:completed_item[ 'info' ] )
call assert_equal( 'W', v:completed_item[ 'kind' ] )
call assert_equal( 'test', v:completed_item[ 'user_data' ] )
let s:called_completedone = 1
endfunction
function Test_CompleteDoneDict()
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDict()
set completefunc=<SID>CompleteDone_CompleteFuncDict
execute "normal a\<C-X>\<C-U>\<C-Y>"
set completefunc&
call assert_equal( 'test', v:completed_item[ 'user_data' ] )
call assert_true( s:called_completedone )
let s:called_completedone = 0
au! CompleteDone
endfunc
function! s:CompleteDone_CompleteFuncDictNoUserData( findstart, base )
if a:findstart
return 0
endif
return {
\ 'words': [
\ {
\ 'word': 'aword',
\ 'abbr': 'wrd',
\ 'menu': 'extra text',
\ 'info': 'words are cool',
\ 'kind': 'W'
\ }
\ ]
\ }
endfunction
function! s:CompleteDone_CheckCompletedItemDictNoUserData()
call assert_equal( 'aword', v:completed_item[ 'word' ] )
call assert_equal( 'wrd', v:completed_item[ 'abbr' ] )
call assert_equal( 'extra text', v:completed_item[ 'menu' ] )
call assert_equal( 'words are cool', v:completed_item[ 'info' ] )
call assert_equal( 'W', v:completed_item[ 'kind' ] )
call assert_equal( '', v:completed_item[ 'user_data' ] )
let s:called_completedone = 1
endfunction
function Test_CompleteDoneDictNoUserData()
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDictNoUserData()
set completefunc=<SID>CompleteDone_CompleteFuncDictNoUserData
execute "normal a\<C-X>\<C-U>\<C-Y>"
set completefunc&
call assert_equal( '', v:completed_item[ 'user_data' ] )
call assert_true( s:called_completedone )
let s:called_completedone = 0
au! CompleteDone
endfunc
function! s:CompleteDone_CompleteFuncList( findstart, base )
if a:findstart
return 0
endif
return [ 'aword' ]
endfunction
function! s:CompleteDone_CheckCompletedItemList()
call assert_equal( 'aword', v:completed_item[ 'word' ] )
call assert_equal( '', v:completed_item[ 'abbr' ] )
call assert_equal( '', v:completed_item[ 'menu' ] )
call assert_equal( '', v:completed_item[ 'info' ] )
call assert_equal( '', v:completed_item[ 'kind' ] )
call assert_equal( '', v:completed_item[ 'user_data' ] )
let s:called_completedone = 1
endfunction
function Test_CompleteDoneList()
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemList()
set completefunc=<SID>CompleteDone_CompleteFuncList
execute "normal a\<C-X>\<C-U>\<C-Y>"
set completefunc&
call assert_equal( '', v:completed_item[ 'user_data' ] )
call assert_true( s:called_completedone )
let s:called_completedone = 0
au! CompleteDone
endfunc
" Check that when using feedkeys() typeahead does not interrupt searching for
" completions.
func Test_compl_feedkeys()
+8
View File
@@ -786,6 +786,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1493,
/**/
1492,
/**/
1491,
/**/
1490,
/**/
1489,
/**/