Hi.

By using following vimrc, "aa" is inserted automatically at the first entering 
insert mode against "noinsert" option.

[repro steps]

vimrc:
----
set nocompatible
set completeopt=menu,noinsert

function! C(...) abort
  if mode() ==# 'i'
    call complete(col('.'), ['aa', 'aaa'])
  else
    call SetCompletion()
  endif
endfunction

function! SetCompletion() abort
  call timer_start(0, 'C')
endfunction

autocmd InsertEnter * call SetCompletion()
----

vim -Nu vimrc

i (enter insert mode)

https://cloud.githubusercontent.com/assets/3213998/14488850/191f341e-01a5-11e6-9068-330431f41fc4.gif


[cause]

completion starts before 'compl_no_insert' (and 'compl_no_select') are set.

'set_completion()' is called via timer, in safe_vgetc().

https://github.com/vim/vim/blob/3780bb9/src/edit.c#L781-L784

but 'compl_no_insert' is set in 'ins_compl_prep()' after that.

https://github.com/vim/vim/blob/3780bb9/src/edit.c#L868


[patch]

add 'set_completeopt()' function and set 'compl_no_insert' and 
'compl_no_select' when ':set completeopt=...' is done.

https://gist.github.com/ichizok/8b7379406fbbdf16fe17fc7ce5494e8e


Thank you.
- Ozaki Kiichi

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui