" Test for completion menu
source shared.vim
source screendump.vim
source check.vim
let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
let g:setting = ''
func ListMonths()
if g:setting != ''
exe ":set" g:setting
endif
let mth = copy(g:months)
let entered = strcharpart(getline('.'),0,col('.'))
if !empty(entered)
let mth = filter(mth, 'v:val=~"^".entered')
endif
call complete(1, mth)
return ''
endfunc
func Test_popup_complete2()
" Although the popupmenu is not visible, this does not mean completion mode
" has ended. After pressing <f5> to complete the currently typed char, Vim
" still stays in the first state of the completion (:h ins-completion-menu),
" although the popupmenu wasn't shown <c-e> will remove the inserted
" completed text (:h complete_CTRL-E), while the following <c-e> will behave
" like expected (:h i_CTRL-E)
new
inoremap <f5> <c-r>=ListMonths()<cr>
call append(1, ["December2015"])
:1
call feedkeys("aD\<f5>\<C-E>\<C-E>\<C-E>\<C-E>\<enter>\<esc>", 'tx')
call assert_equal(["Dece", "", "December2015"], getline(1,3))
%d
bw!
endfunc
func Test_popup_complete()
new
inoremap <f5> <c-r>=ListMonths()<cr>
" <C-E> - select original typed text before