From 713e78dd3962b0d4db03064bd47f98f2c0288ea5 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 29 Jul 2018 20:48:13 +0200 Subject: [PATCH] tests: harden/fix completions with regard to longest/nvim mostly --- test/completions.vim | 62 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/test/completions.vim b/test/completions.vim index aa6db08..8701d8a 100644 --- a/test/completions.vim +++ b/test/completions.vim @@ -13,6 +13,20 @@ describe 'completions' bd! end + it 'longest in completeopt' + " This gets set up with Vim only on VimEnter. + if has('nvim') + Expect stridx(&completeopt, 'longest') > -1 + else + Expect stridx(&completeopt, 'longest') == -1 + doautocmd VimEnter + Expect stridx(&completeopt, 'longest') > -1 + endif + + " Do not use it for following tests. + set completeopt-=longest + end + it 'smart import' exec "normal ifrom os " Expect getline('.') == 'from os import ' @@ -35,20 +49,35 @@ describe 'completions' it 'exception' normal oIndentationErrX Expect getline('.') == 'IndentationError' - normal a().filenaX + + " Do not remap keys (".") here, otherwise this triggers completion in + " Neovim already. + normal! a().filena + + normal aX Expect getline('.') == 'IndentationError().filename' end it 'multi complete' + " NOTE: nvim results in "importErr()" here with completeopt+=longest, + " but Vim is fine. + " This is due to `pumvisible()` in jedi#complete_opened being true + " with nvim still, but it is 0 with Vim, i.e. Vim appears to close + " the pum already (with the tests). + " + " This might be a misunderstanding though, since the test might not + " expect the "import" keyword to be offered for completion?! normal oImpXErrX() Expect getline('.') == 'ImportError()' end it 'cycling through entries popup_select_first=0' + set completeopt+=longest let g:jedi#popup_select_first = 0 execute "normal oraise impX\" - " It looks like this is currently not working properly. - "Expect getline('.') == 'raise ImportError' + + Expect getline('.') == 'raise ImportError' + set completeopt-=longest end it 'cycling through entries popup_select_first=1' @@ -56,12 +85,27 @@ describe 'completions' Expect getline('.') == 'raise ImportWarning' end - it 'longest' - " -longest completes the first one - set completeopt -=longest - execute "normal oraise baseX" - Expect getline('.') == 'raise BaseException' - set completeopt +=longest + it 'cycling through entries popup_select_first=1 and longest' + set completeopt+=longest + execute "normal oraise impX" + Expect getline('.') == 'raise Import' + + " With Neovim pumvisible() is 1 in jedi#complete_opened, which then + " triggers the . This is not the case with Vim. + if has('nvim') + execute "normal oraise impX\" + Expect getline('.') == 'raise ImportWarning' + + execute "normal oraise impX\\" + Expect getline('.') == 'raise imp' + else + execute "normal oraise impX\" + Expect getline('.') == 'raise ImportError' + + execute "normal oraise impX\\" + Expect getline('.') == 'raise ImportWarning' + endif + set completeopt-=longest end end