Patch 8.2.2704

6 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 3, 2021, 2:14:03 PM4/3/21
to vim...@googlegroups.com

Patch 8.2.2704
Problem: Adding a lot of completions can be a bit slow.
Solution: Use fast_breakcheck() instead of ui_breakcheck() when adding a
list of completions. (Ben Jackson, closes #8061)
Files: src/insexpand.c


*** ../vim-8.2.2703/src/insexpand.c 2021-01-29 21:47:20.485738910 +0100
--- src/insexpand.c 2021-04-03 20:11:22.095127230 +0200
***************
*** 118,123 ****
--- 118,124 ----
# define CP_CONT_S_IPOS 4 // use CONT_S_IPOS for compl_cont_status
# define CP_EQUAL 8 // ins_compl_equal() always returns TRUE
# define CP_ICASE 16 // ins_compl_equal() ignores case
+ # define CP_FAST 32 // use fast_breakcheck instead of ui_breakcheck

static char e_hitend[] = N_("Hit end of paragraph");
# ifdef FEAT_COMPL_FUNC
***************
*** 790,796 ****

for (i = 0; i < num_matches && add_r != FAIL; i++)
if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, NULL, dir,
! icase ? CP_ICASE : 0, FALSE)) == OK)
// if dir was BACKWARD then honor it just once
dir = FORWARD;
FreeWild(num_matches, matches);
--- 791,797 ----

for (i = 0; i < num_matches && add_r != FAIL; i++)
if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, NULL, dir,
! CP_FAST | (icase ? CP_ICASE : 0), FALSE)) == OK)
// if dir was BACKWARD then honor it just once
dir = FORWARD;
FreeWild(num_matches, matches);
***************
*** 1567,1573 ****
// Respect the 'backspace' option.
if ((int)(p - line) - (int)compl_col < 0
|| ((int)(p - line) - (int)compl_col == 0
! && ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL
|| (!can_bs(BS_START) && (int)(p - line) - (int)compl_col
- compl_length < 0))
return K_BS;
--- 1568,1575 ----
// Respect the 'backspace' option.
if ((int)(p - line) - (int)compl_col < 0
|| ((int)(p - line) - (int)compl_col == 0
! && ctrl_x_mode != CTRL_X_OMNI)
! || ctrl_x_mode == CTRL_X_EVAL
|| (!can_bs(BS_START) && (int)(p - line) - (int)compl_col
- compl_length < 0))
return K_BS;
***************
*** 2271,2284 ****
* If the given string is already in the list of completions, then return
* NOTDONE, otherwise add it to the list and return OK. If there is an error,
* maybe because alloc() returns NULL, then FAIL is returned.
*/
static int
! ins_compl_add_tv(typval_T *tv, int dir)
{
char_u *word;
int dup = FALSE;
int empty = FALSE;
! int flags = 0;
char_u *(cptext[CPT_COUNT]);
typval_T user_data;

--- 2273,2287 ----
* If the given string is already in the list of completions, then return
* NOTDONE, otherwise add it to the list and return OK. If there is an error,
* maybe because alloc() returns NULL, then FAIL is returned.
+ * When "fast" is TRUE use fast_breakcheck() instead of ui_breakcheck().
*/
static int
! ins_compl_add_tv(typval_T *tv, int dir, int fast)
{
char_u *word;
int dup = FALSE;
int empty = FALSE;
! int flags = fast ? CP_FAST : 0;
char_u *(cptext[CPT_COUNT]);
typval_T user_data;

***************
*** 2329,2335 ****
CHECK_LIST_MATERIALIZE(list);
FOR_ALL_LIST_ITEMS(list, li)
{
! if (ins_compl_add_tv(&li->li_tv, dir) == OK)
// if dir was BACKWARD then honor it just once
dir = FORWARD;
else if (did_emsg)
--- 2332,2338 ----
CHECK_LIST_MATERIALIZE(list);
FOR_ALL_LIST_ITEMS(list, li)
{
! if (ins_compl_add_tv(&li->li_tv, dir, TRUE) == OK)
// if dir was BACKWARD then honor it just once
dir = FORWARD;
else if (did_emsg)
***************
*** 2391,2397 ****
if (p_ic)
flags |= CP_ICASE;
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
! -1, NULL, NULL, NULL, 0, flags, FALSE) != OK)
return;

ctrl_x_mode = CTRL_X_EVAL;
--- 2394,2401 ----
if (p_ic)
flags |= CP_ICASE;
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
! -1, NULL, NULL, NULL, 0,
! flags | CP_FAST, FALSE) != OK)
return;

ctrl_x_mode = CTRL_X_EVAL;
***************
*** 2461,2467 ****
void
f_complete_add(typval_T *argvars, typval_T *rettv)
{
! rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0);
}

/*
--- 2465,2471 ----
void
f_complete_add(typval_T *argvars, typval_T *rettv)
{
! rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0, FALSE);
}

/*
*** ../vim-8.2.2703/src/version.c 2021-04-03 19:32:40.750286283 +0200
--- src/version.c 2021-04-03 20:12:53.262866262 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2704,
/**/

--
hundred-and-one symptoms of being an internet addict:
53. To find out what time it is, you send yourself an e-mail and check the
"Date:" field.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages