mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
vim-patch:9.1.1657: Autocompletion adds delay
Problem: Autocompletion adds delay
(gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).
related: vim/vim#17960
fixes: vim/vim#18022
closes: vim/vim#18048
196c376682
Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
@@ -581,6 +581,10 @@ static int insert_execute(VimState *state, int key)
|
||||
return 1; // continue
|
||||
}
|
||||
|
||||
if (p_ac) {
|
||||
ins_compl_set_autocomplete(true);
|
||||
}
|
||||
|
||||
// A non-white character that fits in with the current
|
||||
// completion: Add to "compl_leader".
|
||||
if (ins_compl_accept_char(s->c)) {
|
||||
@@ -598,6 +602,10 @@ static int insert_execute(VimState *state, int key)
|
||||
return 1; // continue
|
||||
}
|
||||
|
||||
if (p_ac) {
|
||||
ins_compl_set_autocomplete(false);
|
||||
}
|
||||
|
||||
// Pressing CTRL-Y selects the current match. When
|
||||
// compl_enter_selects is set the Enter key does the same.
|
||||
if ((s->c == Ctrl_Y
|
||||
@@ -849,10 +857,11 @@ static int insert_handle_key(InsertState *s)
|
||||
auto_format(false, true);
|
||||
if (s->did_backspace && p_ac && !char_avail() && curwin->w_cursor.col > 0) {
|
||||
s->c = char_before_cursor();
|
||||
if (ins_compl_setup_autocompl(s->c)) {
|
||||
if (vim_isprintc(s->c)) {
|
||||
redraw_later(curwin, UPD_VALID);
|
||||
update_screen(); // Show char deletion immediately
|
||||
ui_flush();
|
||||
ins_compl_set_autocomplete(true);
|
||||
insert_do_complete(s); // Trigger autocompletion
|
||||
return 1;
|
||||
}
|
||||
@@ -1233,10 +1242,11 @@ normalchar:
|
||||
// closed fold.
|
||||
foldOpenCursor();
|
||||
// Trigger autocompletion
|
||||
if (p_ac && !char_avail() && ins_compl_setup_autocompl(s->c)) {
|
||||
if (p_ac && !char_avail() && vim_isprintc(s->c)) {
|
||||
redraw_later(curwin, UPD_VALID);
|
||||
update_screen(); // Show character immediately
|
||||
ui_flush();
|
||||
ins_compl_set_autocomplete(true);
|
||||
insert_do_complete(s);
|
||||
}
|
||||
|
||||
|
@@ -6027,6 +6027,7 @@ int ins_complete(int c, bool enable_pum)
|
||||
|
||||
if (!compl_started) {
|
||||
if (ins_compl_start() == FAIL) {
|
||||
compl_autocomplete = false;
|
||||
return FAIL;
|
||||
}
|
||||
} else if (insert_match && stop_arrow() == FAIL) {
|
||||
@@ -6109,19 +6110,15 @@ int ins_complete(int c, bool enable_pum)
|
||||
}
|
||||
compl_was_interrupted = compl_interrupted;
|
||||
compl_interrupted = false;
|
||||
compl_autocomplete = false;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/// Returns true if the given character 'c' can be used to trigger
|
||||
/// autocompletion.
|
||||
bool ins_compl_setup_autocompl(int c)
|
||||
/// Enable/disable autocompletion
|
||||
void ins_compl_set_autocomplete(bool value)
|
||||
{
|
||||
if (vim_isprintc(c)) {
|
||||
compl_autocomplete = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
compl_autocomplete = value;
|
||||
}
|
||||
|
||||
/// Remove (if needed) and show the popup menu
|
||||
|
Reference in New Issue
Block a user