Skip to content

Commit 8aefbe0

Browse files
committed
patch 7.4.1405
Problem: Completion menu flickers. Solution: Delay showing the popup menu. (Shougo, Justin M. Keyes, closes #656)
1 parent 9186a27 commit 8aefbe0

2 files changed

Lines changed: 36 additions & 20 deletions

File tree

src/edit.c

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ static int ins_compl_key2dir(int c);
185185
static int ins_compl_pum_key(int c);
186186
static int ins_compl_key2count(int c);
187187
static int ins_compl_use_match(int c);
188-
static int ins_complete(int c);
188+
static int ins_complete(int c, int enable_pum);
189+
static void show_pum(int save_w_wrow);
189190
static unsigned quote_meta(char_u *dest, char_u *str, int len);
190191
#endif /* FEAT_INS_EXPAND */
191192

@@ -1429,7 +1430,7 @@ edit(
14291430

14301431
docomplete:
14311432
compl_busy = TRUE;
1432-
if (ins_complete(c) == FAIL)
1433+
if (ins_complete(c, TRUE) == FAIL)
14331434
compl_cont_status = 0;
14341435
compl_busy = FALSE;
14351436
break;
@@ -2765,6 +2766,8 @@ ins_compl_make_cyclic(void)
27652766
void
27662767
set_completion(colnr_T startcol, list_T *list)
27672768
{
2769+
int save_w_wrow = curwin->w_wrow;
2770+
27682771
/* If already doing completions stop it. */
27692772
if (ctrl_x_mode != 0)
27702773
ins_compl_prep(' ');
@@ -2794,11 +2797,15 @@ set_completion(colnr_T startcol, list_T *list)
27942797

27952798
compl_curr_match = compl_first_match;
27962799
if (compl_no_insert)
2797-
ins_complete(K_DOWN);
2800+
ins_complete(K_DOWN, FALSE);
27982801
else
2799-
ins_complete(Ctrl_N);
2802+
ins_complete(Ctrl_N, FALSE);
28002803
if (compl_no_select)
2801-
ins_complete(Ctrl_P);
2804+
ins_complete(Ctrl_P, FALSE);
2805+
2806+
/* Lazily show the popup menu, unless we got interrupted. */
2807+
if (!compl_interrupted)
2808+
show_pum(save_w_wrow);
28022809
out_flush();
28032810
}
28042811

@@ -3484,7 +3491,7 @@ ins_compl_new_leader(void)
34843491
}
34853492
#endif
34863493
compl_restarting = TRUE;
3487-
if (ins_complete(Ctrl_N) == FAIL)
3494+
if (ins_complete(Ctrl_N, TRUE) == FAIL)
34883495
compl_cont_status = 0;
34893496
compl_restarting = FALSE;
34903497
}
@@ -5017,7 +5024,7 @@ ins_compl_use_match(int c)
50175024
* Returns OK if completion was done, FAIL if something failed (out of mem).
50185025
*/
50195026
static int
5020-
ins_complete(int c)
5027+
ins_complete(int c, int enable_pum)
50215028
{
50225029
char_u *line;
50235030
int startcol = 0; /* column where searched text starts */
@@ -5610,27 +5617,34 @@ ins_complete(int c)
56105617
}
56115618

56125619
/* Show the popup menu, unless we got interrupted. */
5613-
if (!compl_interrupted)
5620+
if (enable_pum && !compl_interrupted)
56145621
{
5615-
/* RedrawingDisabled may be set when invoked through complete(). */
5616-
n = RedrawingDisabled;
5617-
RedrawingDisabled = 0;
5618-
5619-
/* If the cursor moved we need to remove the pum first. */
5620-
setcursor();
5621-
if (save_w_wrow != curwin->w_wrow)
5622-
ins_compl_del_pum();
5623-
5624-
ins_compl_show_pum();
5625-
setcursor();
5626-
RedrawingDisabled = n;
5622+
show_pum(save_w_wrow);
56275623
}
56285624
compl_was_interrupted = compl_interrupted;
56295625
compl_interrupted = FALSE;
56305626

56315627
return OK;
56325628
}
56335629

5630+
static void
5631+
show_pum(int save_w_wrow)
5632+
{
5633+
/* RedrawingDisabled may be set when invoked through complete(). */
5634+
int n = RedrawingDisabled;
5635+
5636+
RedrawingDisabled = 0;
5637+
5638+
/* If the cursor moved we need to remove the pum first. */
5639+
setcursor();
5640+
if (save_w_wrow != curwin->w_wrow)
5641+
ins_compl_del_pum();
5642+
5643+
ins_compl_show_pum();
5644+
setcursor();
5645+
RedrawingDisabled = n;
5646+
}
5647+
56345648
/*
56355649
* Looks in the first "len" chars. of "src" for search-metachars.
56365650
* If dest is not NULL the chars. are copied there quoting (with

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static char *(features[]) =
748748

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1405,
751753
/**/
752754
1404,
753755
/**/

0 commit comments

Comments
 (0)