aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-08-12 17:10:48 +0200
committerGitHub <noreply@github.com>2019-08-12 17:10:48 +0200
commita336a05e7e4aab5a7b5e21a676f5531fd6a3fd35 (patch)
tree8f25edf83eb7206b0827aabd4e00ad8f0a34ff83 /src
parent2037028b50af12e628bd966882baa8a7ff9844fe (diff)
downloadrneovim-a336a05e7e4aab5a7b5e21a676f5531fd6a3fd35.tar.gz
rneovim-a336a05e7e4aab5a7b5e21a676f5531fd6a3fd35.tar.bz2
rneovim-a336a05e7e4aab5a7b5e21a676f5531fd6a3fd35.zip
testdir/test_popup.vim: sync/align with Vim (#10751)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/testdir/test_popup.vim160
1 files changed, 81 insertions, 79 deletions
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 98e9de9ffb..7d844e055c 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -14,7 +14,7 @@ func ListMonths()
if !empty(entered)
let mth = filter(mth, 'v:val=~"^".entered')
endif
- call complete(1, mth)
+ call complete(1, mth)
return ''
endfunc
@@ -72,7 +72,7 @@ func Test_popup_complete()
call feedkeys("aJu\<f5>\<c-p>l\<c-y>", 'tx')
call assert_equal(["Jul"], getline(1,2))
%d
-
+
" any-non printable, non-white character: Add this character and
" reduce number of matches
call feedkeys("aJu\<f5>\<c-p>l\<c-n>\<c-y>", 'tx')
@@ -94,7 +94,7 @@ func Test_popup_complete()
call feedkeys("aJ\<f5>".repeat("\<c-n>",3)."\<c-l>\<esc>", 'tx')
call assert_equal(["J "], getline(1,2))
%d
-
+
" <c-l> - Insert one character from the current match
call feedkeys("aJ\<f5>".repeat("\<c-n>",4)."\<c-l>\<esc>", 'tx')
call assert_equal(["January "], getline(1,2))
@@ -516,6 +516,35 @@ func Test_completion_ctrl_e_without_autowrap()
q!
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()
new
let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"]
@@ -575,82 +604,6 @@ func Test_completion_comment_formatting()
bwipe!
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()
for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep")
call complete_add(m)
@@ -740,6 +693,55 @@ func Test_popup_and_window_resize()
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 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()
new
inoremap <buffer><F5> <C-R>=complete_info().mode<CR>