test_ins_complete_no_halt.vim 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. " Test insert mode completion does not get stuck when looping around.
  2. " In a separate file to avoid the settings to leak to other test cases.
  3. set complete+=kspell
  4. set completeopt+=menu
  5. set completeopt+=menuone
  6. set completeopt+=noselect
  7. set completeopt+=noinsert
  8. let g:autocompletion = v:true
  9. func Test_ins_complete_no_halt()
  10. function! OpenCompletion()
  11. if pumvisible() && (g:autocompletion == v:true)
  12. call feedkeys("\<C-e>\<C-n>", "i")
  13. return
  14. endif
  15. if ((v:char >= 'a' && v:char <= 'z') || (v:char >= 'A' && v:char <= 'Z')) && (g:autocompletion == v:true)
  16. call feedkeys("\<C-n>", "i")
  17. redraw
  18. endif
  19. endfunction
  20. autocmd InsertCharPre * noautocmd call OpenCompletion()
  21. setlocal spell! spelllang=en_us
  22. call feedkeys("iauto-complete-halt-test test test test test test test test test test test test test test test test test test test\<C-c>", "tx!")
  23. call assert_equal(["auto-complete-halt-test test test test test test test test test test test test test test test test test test test"], getline(1, "$"))
  24. endfunc
  25. func Test_auto_complete_backwards_no_halt()
  26. function! OpenCompletion()
  27. if pumvisible() && (g:autocompletion == v:true)
  28. call feedkeys("\<C-e>\<C-p>", "i")
  29. return
  30. endif
  31. if ((v:char >= 'a' && v:char <= 'z') || (v:char >= 'A' && v:char <= 'Z')) && (g:autocompletion == v:true)
  32. call feedkeys("\<C-p>", "i")
  33. redraw
  34. endif
  35. endfunction
  36. autocmd InsertCharPre * noautocmd call OpenCompletion()
  37. setlocal spell! spelllang=en_us
  38. call feedkeys("iauto-complete-halt-test test test test test test test test test test test test test test test test test test test\<C-c>", "tx!")
  39. call assert_equal(["auto-complete-halt-test test test test test test test test test test test test test test test test test test test"], getline(1, "$"))
  40. endfunc
  41. " vim: shiftwidth=2 sts=2 expandtab