mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
testdir/test_popup.vim: sync/align with Vim (#10751)
This commit is contained in:
@@ -516,6 +516,35 @@ func Test_completion_ctrl_e_without_autowrap()
|
|||||||
q!
|
q!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func DummyCompleteSix()
|
||||||
|
call complete(1, ['Hello', 'World'])
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" complete() correctly clears the list of autocomplete candidates
|
||||||
|
" See #1411
|
||||||
|
func Test_completion_clear_candidate_list()
|
||||||
|
new
|
||||||
|
%d
|
||||||
|
" select first entry from the completion popup
|
||||||
|
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>", "tx")
|
||||||
|
call assert_equal('Hello', getline(1))
|
||||||
|
%d
|
||||||
|
" select second entry from the completion popup
|
||||||
|
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>", "tx")
|
||||||
|
call assert_equal('World', getline(1))
|
||||||
|
%d
|
||||||
|
" select original text
|
||||||
|
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>", "tx")
|
||||||
|
call assert_equal(' xxx', getline(1))
|
||||||
|
%d
|
||||||
|
" back at first entry from completion list
|
||||||
|
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>\<C-N>", "tx")
|
||||||
|
call assert_equal('Hello', getline(1))
|
||||||
|
|
||||||
|
bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_completion_respect_bs_option()
|
func Test_completion_respect_bs_option()
|
||||||
new
|
new
|
||||||
let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"]
|
let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"]
|
||||||
@@ -575,82 +604,6 @@ func Test_completion_comment_formatting()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func DummyCompleteSix()
|
|
||||||
call complete(1, ['Hello', 'World'])
|
|
||||||
return ''
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" complete() correctly clears the list of autocomplete candidates
|
|
||||||
func Test_completion_clear_candidate_list()
|
|
||||||
new
|
|
||||||
%d
|
|
||||||
" select first entry from the completion popup
|
|
||||||
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>", "tx")
|
|
||||||
call assert_equal('Hello', getline(1))
|
|
||||||
%d
|
|
||||||
" select second entry from the completion popup
|
|
||||||
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>", "tx")
|
|
||||||
call assert_equal('World', getline(1))
|
|
||||||
%d
|
|
||||||
" select original text
|
|
||||||
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>", "tx")
|
|
||||||
call assert_equal(' xxx', getline(1))
|
|
||||||
%d
|
|
||||||
" back at first entry from completion list
|
|
||||||
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>\<C-N>", "tx")
|
|
||||||
call assert_equal('Hello', getline(1))
|
|
||||||
|
|
||||||
bw!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_popup_complete_backwards()
|
|
||||||
new
|
|
||||||
call setline(1, ['Post', 'Port', 'Po'])
|
|
||||||
let expected=['Post', 'Port', 'Port']
|
|
||||||
call cursor(3,2)
|
|
||||||
call feedkeys("A\<C-X>". repeat("\<C-P>", 3). "rt\<cr>", 'tx')
|
|
||||||
call assert_equal(expected, getline(1,'$'))
|
|
||||||
bwipe!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_popup_and_preview_autocommand()
|
|
||||||
" This used to crash Vim
|
|
||||||
if !has('python')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let h = winheight(0)
|
|
||||||
if h < 15
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
new
|
|
||||||
augroup MyBufAdd
|
|
||||||
au!
|
|
||||||
au BufAdd * nested tab sball
|
|
||||||
augroup END
|
|
||||||
set omnifunc=pythoncomplete#Complete
|
|
||||||
call setline(1, 'import os')
|
|
||||||
" make the line long
|
|
||||||
call setline(2, ' os.')
|
|
||||||
$
|
|
||||||
call feedkeys("A\<C-X>\<C-O>\<C-N>\<C-N>\<C-N>\<enter>\<esc>", 'tx')
|
|
||||||
call assert_equal("import os", getline(1))
|
|
||||||
call assert_match(' os.\(EX_IOERR\|O_CREAT\)$', getline(2))
|
|
||||||
call assert_equal(1, winnr('$'))
|
|
||||||
" previewwindow option is not set
|
|
||||||
call assert_equal(0, &previewwindow)
|
|
||||||
norm! gt
|
|
||||||
call assert_equal(0, &previewwindow)
|
|
||||||
norm! gT
|
|
||||||
call assert_equal(10, tabpagenr('$'))
|
|
||||||
tabonly
|
|
||||||
pclose
|
|
||||||
augroup MyBufAdd
|
|
||||||
au!
|
|
||||||
augroup END
|
|
||||||
augroup! MyBufAdd
|
|
||||||
bw!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func MessCompleteMonths()
|
func MessCompleteMonths()
|
||||||
for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep")
|
for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep")
|
||||||
call complete_add(m)
|
call complete_add(m)
|
||||||
@@ -740,6 +693,55 @@ func Test_popup_and_window_resize()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_popup_and_preview_autocommand()
|
||||||
|
" This used to crash Vim
|
||||||
|
if !has('python')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let h = winheight(0)
|
||||||
|
if h < 15
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
new
|
||||||
|
augroup MyBufAdd
|
||||||
|
au!
|
||||||
|
au BufAdd * nested tab sball
|
||||||
|
augroup END
|
||||||
|
set omnifunc=pythoncomplete#Complete
|
||||||
|
call setline(1, 'import os')
|
||||||
|
" make the line long
|
||||||
|
call setline(2, ' os.')
|
||||||
|
$
|
||||||
|
call feedkeys("A\<C-X>\<C-O>\<C-N>\<C-N>\<C-N>\<enter>\<esc>", 'tx')
|
||||||
|
call assert_equal("import os", getline(1))
|
||||||
|
call assert_match(' os.\(EX_IOERR\|O_CREAT\)$', getline(2))
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
" previewwindow option is not set
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
norm! gt
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
norm! gT
|
||||||
|
call assert_equal(10, tabpagenr('$'))
|
||||||
|
tabonly
|
||||||
|
pclose
|
||||||
|
augroup MyBufAdd
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! MyBufAdd
|
||||||
|
bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
|
func Test_popup_complete_backwards()
|
||||||
|
new
|
||||||
|
call setline(1, ['Post', 'Port', 'Po'])
|
||||||
|
let expected=['Post', 'Port', 'Port']
|
||||||
|
call cursor(3,2)
|
||||||
|
call feedkeys("A\<C-X>". repeat("\<C-P>", 3). "rt\<cr>", 'tx')
|
||||||
|
call assert_equal(expected, getline(1,'$'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_popup_complete_info_01()
|
func Test_popup_complete_info_01()
|
||||||
new
|
new
|
||||||
inoremap <buffer><F5> <C-R>=complete_info().mode<CR>
|
inoremap <buffer><F5> <C-R>=complete_info().mode<CR>
|
||||||
|
Reference in New Issue
Block a user