mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
vim-patch:9.1.1825: completion: flicker when LSP server is slow (#36020)
Problem: completion: flicker when LSP server is slow
Solution: reinsert leader text before invoking user function
(Girish Palya)
Reference:
https://github.com/girishji/vimcomplete/issues/101#issuecomment-3343063245
In insert-mode completion, the leader text is temporarily removed while
searching for candidates. When the LSP server responds slowly, the
client may call `:sleep` to wait, which triggers `out_flush()`. This
causes the deleted text to disappear briefly before being redrawn,
resulting in visible flicker.
This commit reinserts the leader text before invoking the user function,
and removes it again afterward to eliminate flicker.
closes: vim/vim#18468
c51d1cc578
Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
@@ -6544,16 +6544,29 @@ static void remove_old_matches(void)
|
||||
/// 'refresh:always' flag.
|
||||
static void get_cpt_func_completion_matches(Callback *cb)
|
||||
{
|
||||
int startcol = cpt_sources_array[cpt_sources_index].cs_startcol;
|
||||
cpt_source_T *cpt_src = &cpt_sources_array[cpt_sources_index];
|
||||
int startcol = cpt_src->cs_startcol;
|
||||
|
||||
if (startcol == -2 || startcol == -3) {
|
||||
return;
|
||||
}
|
||||
|
||||
set_compl_globals(startcol, curwin->w_cursor.col, true);
|
||||
|
||||
// Insert the leader string (previously removed) before expansion.
|
||||
// This prevents flicker when `func` (e.g. an LSP client) is slow and
|
||||
// calls 'sleep', which triggers ui_flush().
|
||||
if (!cpt_src->cs_refresh_always) {
|
||||
ins_compl_insert_bytes(ins_compl_leader(), -1);
|
||||
}
|
||||
|
||||
expand_by_function(0, cpt_compl_pattern.data, cb);
|
||||
|
||||
cpt_sources_array[cpt_sources_index].cs_refresh_always = compl_opt_refresh_always;
|
||||
if (!cpt_src->cs_refresh_always) {
|
||||
ins_compl_delete(false);
|
||||
}
|
||||
|
||||
cpt_src->cs_refresh_always = compl_opt_refresh_always;
|
||||
compl_opt_refresh_always = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user