@@ -378,7 +378,7 @@ func DummyCompleteFour(findstart, base)
378378 endif
379379endfunc
380380
381- " Test that 'completefunc ' works when it's OK.
381+ " Test that 'omnifunc ' works when it's OK.
382382func Test_omnifunc_with_check ()
383383 new
384384 setlocal omnifunc = DummyCompleteFour
@@ -437,5 +437,31 @@ func Test_complete_no_undo()
437437 q !
438438endfunc
439439
440+ function ! DummyCompleteFive (findstart, base)
441+ if a: findstart
442+ return 0
443+ else
444+ return [
445+ \ { ' word' : ' January' , ' info' : " info1-1\n 1-2\n 1-3" },
446+ \ { ' word' : ' February' , ' info' : " info2-1\n 2-2\n 2-3" },
447+ \ { ' word' : ' March' , ' info' : " info3-1\n 3-2\n 3-3" },
448+ \ { ' word' : ' April' , ' info' : " info4-1\n 4-2\n 4-3" },
449+ \ { ' word' : ' May' , ' info' : " info5-1\n 5-2\n 5-3" },
450+ \ ]
451+ endif
452+ endfunc
453+
454+ " Test that 'completefunc' on Scratch buffer with preview window works when
455+ " it's OK.
456+ func Test_completefunc_with_scratch_buffer ()
457+ new + setlocal \ buftype = nofile\ bufhidden = wipe\ noswapfile
458+ set completeopt += preview
459+ setlocal completefunc = DummyCompleteFive
460+ call feedkeys (" A\<C-X>\<C-U>\<C-N>\<C-N>\<C-N>\<Esc> " , " x" )
461+ call assert_equal ([' April' ], getline (1 , ' $' ))
462+ pclose
463+ q !
464+ set completeopt &
465+ endfunc
440466
441467" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments