Skip to content

Commit a3f7952

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 4cdf6de + 9b56a57 commit a3f7952

13 files changed

Lines changed: 259 additions & 24 deletions

File tree

runtime/doc/insert.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*insert.txt* For Vim version 8.0. Last change: 2018 Jan 26
1+
*insert.txt* For Vim version 8.0. Last change: 2018 Feb 10
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1103,6 +1103,8 @@ items:
11031103
item with the same word is already present.
11041104
empty when non-zero this match will be added even when it is
11051105
an empty string
1106+
user_data custom data which is associated with the item and
1107+
available in |v:completed_item|
11061108

11071109
All of these except "icase", "dup" and "empty" must be a string. If an item
11081110
does not meet these requirements then an error message is given and further
@@ -1196,6 +1198,8 @@ The menu is used when:
11961198

11971199
The 'pumheight' option can be used to set a maximum height. The default is to
11981200
use all space available.
1201+
The 'pumwidth' option can be used to set a minimum width. The default is 15
1202+
characters.
11991203

12001204
There are three states:
12011205
1. A complete match has been inserted, e.g., after using CTRL-N or CTRL-P.

runtime/doc/options.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6114,6 +6114,16 @@ A jump table for the options with a short description can be found at |Q_op|.
61146114
{not in Vi}
61156115
Determines the maximum number of items to show in the popup menu for
61166116
Insert mode completion. When zero as much space as available is used.
6117+
|ins-completion-menu|.
6118+
6119+
*'pumwidth'* *'pw'*
6120+
'pumwidth' 'pw' number (default 0)
6121+
global
6122+
{not available when compiled without the
6123+
|+insert_expand| feature}
6124+
{not in Vi}
6125+
Determines the minium width to use for the popup menu for Insert mode
6126+
completion. When zero the default of 15 screen cells is used.
61176127
|ins-completion-menu|.
61186128

61196129
*'pythondll'*

src/edit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,6 +4250,8 @@ ins_compl_add_tv(typval_T *tv, int dir)
42504250
(char_u *)"kind", FALSE);
42514251
cptext[CPT_INFO] = get_dict_string(tv->vval.v_dict,
42524252
(char_u *)"info", FALSE);
4253+
cptext[CPT_USER_DATA] = get_dict_string(tv->vval.v_dict,
4254+
(char_u *)"user_data", FALSE);
42534255
if (get_dict_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL)
42544256
icase = get_dict_number(tv->vval.v_dict, (char_u *)"icase");
42554257
if (get_dict_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL)
@@ -4772,6 +4774,8 @@ ins_compl_insert(int in_compl_func)
47724774
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_KIND]));
47734775
dict_add_nr_str(dict, "info", 0L,
47744776
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_INFO]));
4777+
dict_add_nr_str(dict, "user_data", 0L,
4778+
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_USER_DATA]));
47754779
}
47764780
set_vim_var_dict(VV_COMPLETED_ITEM, dict);
47774781
if (!in_compl_func)

src/evalfunc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,8 @@ f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
14471447
/* Skip the first and last item, they are always empty. */
14481448
for (i = 1; i < size - 1; ++i)
14491449
list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
1450+
while (size > 0)
1451+
vim_free(array[--size].pum_text);
14501452
vim_free(array);
14511453
}
14521454
}

src/misc2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,10 @@ free_all_mem(void)
11161116
spell_free_all();
11171117
# endif
11181118

1119+
#if defined(FEAT_INS_EXPAND) && defined(FEAT_BEVAL_TERM)
1120+
ui_remove_balloon();
1121+
# endif
1122+
11191123
# if defined(FEAT_USR_CMDS)
11201124
/* Clear user commands (before deleting buffers). */
11211125
ex_comclear(NULL);

src/option.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,13 @@ static struct vimoption options[] =
23132313
(char_u *)&p_ph, PV_NONE,
23142314
#else
23152315
(char_u *)NULL, PV_NONE,
2316+
#endif
2317+
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2318+
{"pumwidth", "pw", P_NUM|P_VI_DEF,
2319+
#ifdef FEAT_INS_EXPAND
2320+
(char_u *)&p_pw, PV_NONE,
2321+
#else
2322+
(char_u *)NULL, PV_NONE,
23162323
#endif
23172324
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
23182325
{"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,

src/option.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ EXTERN int p_cp; /* 'compatible' */
424424
#ifdef FEAT_INS_EXPAND
425425
EXTERN char_u *p_cot; /* 'completeopt' */
426426
EXTERN long p_ph; /* 'pumheight' */
427+
EXTERN long p_pw; /* 'pumwidth' */
427428
#endif
428429
EXTERN char_u *p_cpo; /* 'cpoptions' */
429430
#ifdef FEAT_CSCOPE

src/popupmnu.c

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ pum_compute_size(void)
6666
}
6767
}
6868

69+
/*
70+
* Return the minimum width of the popup menu.
71+
*/
72+
static int
73+
pum_get_width(void)
74+
{
75+
return p_pw == 0 ? PUM_DEF_WIDTH : p_pw;
76+
}
77+
6978
/*
7079
* Show the popup menu with items "array[size]".
7180
* "array" must remain valid until pum_undisplay() is called!
@@ -93,7 +102,7 @@ pum_display(
93102

94103
do
95104
{
96-
def_width = PUM_DEF_WIDTH;
105+
def_width = pum_get_width();
97106
above_row = 0;
98107
below_row = cmdline_row;
99108

@@ -216,16 +225,17 @@ pum_display(
216225
if (def_width < max_width)
217226
def_width = max_width;
218227

219-
if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
228+
if (((col < Columns - pum_get_width() || col < Columns - max_width)
220229
#ifdef FEAT_RIGHTLEFT
221230
&& !curwin->w_p_rl)
222-
|| (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width)
231+
|| (curwin->w_p_rl && (col > pum_get_width() || col > max_width)
223232
#endif
224233
))
225234
{
226235
/* align pum column with "col" */
227236
pum_col = col;
228237

238+
/* start with the maximum space available */
229239
#ifdef FEAT_RIGHTLEFT
230240
if (curwin->w_p_rl)
231241
pum_width = pum_col - pum_scrollbar + 1;
@@ -234,12 +244,71 @@ pum_display(
234244
pum_width = Columns - pum_col - pum_scrollbar;
235245

236246
if (pum_width > max_width + pum_kind_width + pum_extra_width + 1
237-
&& pum_width > PUM_DEF_WIDTH)
247+
&& pum_width > pum_get_width())
238248
{
249+
/* the width is too much, make it narrower */
239250
pum_width = max_width + pum_kind_width + pum_extra_width + 1;
240-
if (pum_width < PUM_DEF_WIDTH)
241-
pum_width = PUM_DEF_WIDTH;
251+
if (pum_width < pum_get_width())
252+
pum_width = pum_get_width();
242253
}
254+
else if (((col > pum_get_width() || col > max_width)
255+
#ifdef FEAT_RIGHTLEFT
256+
&& !curwin->w_p_rl)
257+
|| (curwin->w_p_rl && (col < Columns - pum_get_width()
258+
|| col < Columns - max_width)
259+
#endif
260+
))
261+
{
262+
/* align right pum edge with "col" */
263+
#ifdef FEAT_RIGHTLEFT
264+
if (curwin->w_p_rl)
265+
{
266+
pum_col = col + max_width + pum_scrollbar + 1;
267+
if (pum_col >= Columns)
268+
pum_col = Columns - 1;
269+
}
270+
else
271+
#endif
272+
{
273+
pum_col = col - max_width - pum_scrollbar;
274+
if (pum_col < 0)
275+
pum_col = 0;
276+
}
277+
278+
#ifdef FEAT_RIGHTLEFT
279+
if (curwin->w_p_rl)
280+
pum_width = W_ENDCOL(curwin) - pum_col - pum_scrollbar + 1;
281+
else
282+
#endif
283+
pum_width = pum_col - pum_scrollbar;
284+
285+
if (pum_width < pum_get_width())
286+
{
287+
pum_width = pum_get_width();
288+
#ifdef FEAT_RIGHTLEFT
289+
if (curwin->w_p_rl)
290+
{
291+
if (pum_width > pum_col)
292+
pum_width = pum_col;
293+
}
294+
else
295+
#endif
296+
{
297+
if (pum_width >= Columns - pum_col)
298+
pum_width = Columns - pum_col - 1;
299+
}
300+
}
301+
else if (pum_width > max_width + pum_kind_width
302+
+ pum_extra_width + 1
303+
&& pum_width > pum_get_width())
304+
{
305+
pum_width = max_width + pum_kind_width
306+
+ pum_extra_width + 1;
307+
if (pum_width < pum_get_width())
308+
pum_width = pum_get_width();
309+
}
310+
}
311+
243312
}
244313
else if (Columns < def_width)
245314
{
@@ -254,8 +323,8 @@ pum_display(
254323
}
255324
else
256325
{
257-
if (max_width > PUM_DEF_WIDTH)
258-
max_width = PUM_DEF_WIDTH; /* truncate */
326+
if (max_width > pum_get_width())
327+
max_width = pum_get_width(); /* truncate */
259328
#ifdef FEAT_RIGHTLEFT
260329
if (curwin->w_p_rl)
261330
pum_col = max_width - 1;
@@ -1005,4 +1074,5 @@ ui_may_remove_balloon(void)
10051074
ui_remove_balloon();
10061075
}
10071076
# endif
1077+
10081078
#endif

src/spell.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
byte, thus it can't be above 255.
3535
Must be >= PFD_NOTSPECIAL. */
3636

37+
#define MAXREGIONS 8 /* Number of regions supported. */
38+
3739
/* Type used for indexes in the word tree need to be at least 4 bytes. If int
3840
* is 8 bytes we could use something smaller, but what? */
3941
#if VIM_SIZEOF_INT > 3
@@ -80,7 +82,8 @@ struct slang_S
8082

8183
char_u *sl_info; /* infotext string or NULL */
8284

83-
char_u sl_regions[17]; /* table with up to 8 region names plus NUL */
85+
char_u sl_regions[MAXREGIONS * 2 + 1];
86+
/* table with up to 8 region names plus NUL */
8487

8588
char_u *sl_midword; /* MIDWORD string or NULL */
8689

src/spellfile.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
* website, etc)
5555
*
5656
* sectionID == SN_REGION: <regionname> ...
57-
* <regionname> 2 bytes Up to 8 region names: ca, au, etc. Lower case.
58-
* First <regionname> is region 1.
57+
* <regionname> 2 bytes Up to MAXREGIONS region names: ca, au, etc. Lower
58+
* case. First <regionname> is region 1.
5959
*
6060
* sectionID == SN_CHARFLAGS: <charflagslen> <charflags>
6161
* <folcharslen> <folchars>
@@ -832,7 +832,7 @@ read_region_section(FILE *fd, slang_T *lp, int len)
832832
{
833833
int i;
834834

835-
if (len > 16)
835+
if (len > MAXREGIONS * 2)
836836
return SP_FORMERROR;
837837
for (i = 0; i < len; ++i)
838838
lp->sl_regions[i] = getc(fd); /* <regionname> */
@@ -1952,8 +1952,9 @@ typedef struct spellinfo_S
19521952
char_u *si_info; /* info text chars or NULL */
19531953
int si_region_count; /* number of regions supported (1 when there
19541954
are no regions) */
1955-
char_u si_region_name[17]; /* region names; used only if
1956-
* si_region_count > 1) */
1955+
char_u si_region_name[MAXREGIONS * 2 + 1];
1956+
/* region names; used only if
1957+
* si_region_count > 1) */
19571958

19581959
garray_T si_rep; /* list of fromto_T entries from REP lines */
19591960
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)
42344235
else
42354236
{
42364237
line += 8;
4237-
if (STRLEN(line) > 16)
4238+
if (STRLEN(line) > MAXREGIONS * 2)
42384239
smsg((char_u *)_("Too many regions in %s line %d: %s"),
42394240
fname, lnum, line);
42404241
else
@@ -5954,7 +5955,7 @@ mkspell(
59545955
char_u *wfname;
59555956
char_u **innames;
59565957
int incount;
5957-
afffile_T *(afile[8]);
5958+
afffile_T *(afile[MAXREGIONS]);
59585959
int i;
59595960
int len;
59605961
stat_T st;
@@ -6025,8 +6026,8 @@ mkspell(
60256026
EMSG(_(e_invarg)); /* need at least output and input names */
60266027
else if (vim_strchr(gettail(wfname), '_') != NULL)
60276028
EMSG(_("E751: Output file name must not have region name"));
6028-
else if (incount > 8)
6029-
EMSG(_("E754: Only up to 8 regions supported"));
6029+
else if (incount > MAXREGIONS)
6030+
EMSGN(_("E754: Only up to %ld regions supported"), MAXREGIONS);
60306031
else
60316032
{
60326033
/* Check for overwriting before doing things that may take a lot of

0 commit comments

Comments
 (0)