Skip to content

Commit

Permalink
fix(completion): avoid unnecessary redraw for floating window (#3151)
Browse files Browse the repository at this point in the history
"suggest.enablePreselect": true, neovim may use `nvim_select_popupmenu_item`
to preselect matched item which will fire `CompleteChanged` event to
redraw detail. We should use `noa complete()` to avoid unnecessary redraw.
  • Loading branch information
kevinhwang91 authored Jun 21, 2021
1 parent 10cfe59 commit acd723d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions autoload/coc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ endfunction
function! coc#_complete() abort
let items = get(g:coc#_context, 'candidates', [])
let preselect = get(g:coc#_context, 'preselect', -1)
call complete(
\ g:coc#_context.start + 1,
\ items)
let startcol = g:coc#_context.start + 1
if s:select_api && len(items) && preselect != -1
noa call complete(startcol, items)
call nvim_select_popupmenu_item(preselect, v:false, v:false, {})
else
call complete(startcol, items)
endif
return ''
endfunction
Expand Down

0 comments on commit acd723d

Please sign in to comment.