mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #4315 from justinmk/compl_flicker
completion: Avoid flicker
This commit is contained in:
commit
37d6004251
@ -1247,7 +1247,7 @@ normalchar:
|
||||
static void insert_do_complete(InsertState *s)
|
||||
{
|
||||
compl_busy = true;
|
||||
if (ins_complete(s->c) == FAIL) {
|
||||
if (ins_complete(s->c, true) == FAIL) {
|
||||
compl_cont_status = 0;
|
||||
}
|
||||
compl_busy = false;
|
||||
@ -2321,9 +2321,10 @@ static int ins_compl_make_cyclic(void)
|
||||
*/
|
||||
void set_completion(colnr_T startcol, list_T *list)
|
||||
{
|
||||
/* If already doing completions stop it. */
|
||||
if (ctrl_x_mode != 0)
|
||||
// If already doing completions stop it.
|
||||
if (ctrl_x_mode != 0) {
|
||||
ins_compl_prep(' ');
|
||||
}
|
||||
ins_compl_clear();
|
||||
|
||||
if (stop_arrow() == FAIL)
|
||||
@ -2349,16 +2350,23 @@ void set_completion(colnr_T startcol, list_T *list)
|
||||
compl_started = TRUE;
|
||||
compl_used_match = TRUE;
|
||||
compl_cont_status = 0;
|
||||
int save_w_wrow = curwin->w_wrow;
|
||||
|
||||
compl_curr_match = compl_first_match;
|
||||
if (compl_no_insert) {
|
||||
ins_complete(K_DOWN);
|
||||
ins_complete(K_DOWN, false);
|
||||
} else {
|
||||
ins_complete(Ctrl_N);
|
||||
ins_complete(Ctrl_N, false);
|
||||
if (compl_no_select) {
|
||||
ins_complete(Ctrl_P);
|
||||
ins_complete(Ctrl_P, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Lazily show the popup menu, unless we got interrupted.
|
||||
if (!compl_interrupted) {
|
||||
show_pum(save_w_wrow);
|
||||
}
|
||||
|
||||
ui_flush();
|
||||
}
|
||||
|
||||
@ -2935,18 +2943,17 @@ static void ins_compl_new_leader(void)
|
||||
ins_bytes(compl_leader + ins_compl_len());
|
||||
compl_used_match = FALSE;
|
||||
|
||||
if (compl_started)
|
||||
if (compl_started) {
|
||||
ins_compl_set_original_text(compl_leader);
|
||||
else {
|
||||
spell_bad_len = 0; /* need to redetect bad word */
|
||||
/*
|
||||
* Matches were cleared, need to search for them now.
|
||||
* Set "compl_restarting" to avoid that the first match is inserted.
|
||||
*/
|
||||
compl_restarting = TRUE;
|
||||
if (ins_complete(Ctrl_N) == FAIL)
|
||||
} else {
|
||||
spell_bad_len = 0; // need to redetect bad word
|
||||
// Matches were cleared, need to search for them now.
|
||||
// Set "compl_restarting" to avoid that the first match is inserted.
|
||||
compl_restarting = true;
|
||||
if (ins_complete(Ctrl_N, true) == FAIL) {
|
||||
compl_cont_status = 0;
|
||||
compl_restarting = FALSE;
|
||||
}
|
||||
compl_restarting = false;
|
||||
}
|
||||
|
||||
compl_enter_selects = !compl_used_match;
|
||||
@ -4298,7 +4305,7 @@ static int ins_compl_use_match(int c)
|
||||
* Called when character "c" was typed, which has a meaning for completion.
|
||||
* Returns OK if completion was done, FAIL if something failed.
|
||||
*/
|
||||
static int ins_complete(int c)
|
||||
static int ins_complete(int c, bool enable_pum)
|
||||
{
|
||||
char_u *line;
|
||||
int startcol = 0; /* column where searched text starts */
|
||||
@ -4781,20 +4788,9 @@ static int ins_complete(int c)
|
||||
}
|
||||
}
|
||||
|
||||
/* Show the popup menu, unless we got interrupted. */
|
||||
if (!compl_interrupted) {
|
||||
/* RedrawingDisabled may be set when invoked through complete(). */
|
||||
n = RedrawingDisabled;
|
||||
RedrawingDisabled = 0;
|
||||
|
||||
/* If the cursor moved we need to remove the pum first. */
|
||||
setcursor();
|
||||
if (save_w_wrow != curwin->w_wrow)
|
||||
ins_compl_del_pum();
|
||||
|
||||
ins_compl_show_pum();
|
||||
setcursor();
|
||||
RedrawingDisabled = n;
|
||||
// Show the popup menu, unless we got interrupted.
|
||||
if (enable_pum && !compl_interrupted) {
|
||||
show_pum(save_w_wrow);
|
||||
}
|
||||
compl_was_interrupted = compl_interrupted;
|
||||
compl_interrupted = FALSE;
|
||||
@ -8520,3 +8516,20 @@ static char_u *do_insert_char_pre(int c)
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void show_pum(int save_w_wrow)
|
||||
{
|
||||
// RedrawingDisabled may be set when invoked through complete().
|
||||
int n = RedrawingDisabled;
|
||||
RedrawingDisabled = 0;
|
||||
|
||||
// If the cursor moved we need to remove the pum first.
|
||||
setcursor();
|
||||
if (save_w_wrow != curwin->w_wrow) {
|
||||
ins_compl_del_pum();
|
||||
}
|
||||
|
||||
ins_compl_show_pum();
|
||||
setcursor();
|
||||
RedrawingDisabled = n;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user