summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-10-15 17:06:47 +0200
committerBram Moolenaar <Bram@vim.org>2016-10-15 17:06:47 +0200
commit472e85970ee3a80abd824bef510df12e9cfe9e96 (patch)
tree27fae571dfc2e3bf1c7a6b4dfbc59bc5b13356b8 /src/testdir
parent9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8 (diff)
downloadvim-git-472e85970ee3a80abd824bef510df12e9cfe9e96.tar.gz
patch 8.0.0035v8.0.0035
Problem: Order of matches for 'omnifunc' is messed up. (Danny Su) Solution: Do not set compl_curr_match when called from complete_check(). (closes #1168)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/Make_all.mak1
-rw-r--r--src/testdir/test76.in46
-rw-r--r--src/testdir/test76.ok4
-rw-r--r--src/testdir/test_popup.vim111
4 files changed, 111 insertions, 51 deletions
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index a99758048..a8ea54318 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -55,7 +55,6 @@ SCRIPTS_ALL = \
test70.out \
test73.out \
test75.out \
- test76.out \
test77.out \
test79.out \
test80.out \
diff --git a/src/testdir/test76.in b/src/testdir/test76.in
deleted file mode 100644
index db7ebe216..000000000
--- a/src/testdir/test76.in
+++ /dev/null
@@ -1,46 +0,0 @@
-Tests for completefunc/omnifunc. vim: set ft=vim :
-
-STARTTEST
-:"Test that nothing happens if the 'completefunc' opens
-:"a new window (no completion, no crash)
-:so small.vim
-:function! DummyCompleteOne(findstart, base)
-: if a:findstart
-: return 0
-: else
-: wincmd n
-: return ['onedef', 'oneDEF']
-: endif
-:endfunction
-:setlocal completefunc=DummyCompleteOne
-/^one
-A:q!
-:function! DummyCompleteTwo(findstart, base)
-: if a:findstart
-: wincmd n
-: return 0
-: else
-: return ['twodef', 'twoDEF']
-: endif
-:endfunction
-:setlocal completefunc=DummyCompleteTwo
-/^two
-A:q!
-:"Test that 'completefunc' works when it's OK.
-:function! DummyCompleteThree(findstart, base)
-: if a:findstart
-: return 0
-: else
-: return ['threedef', 'threeDEF']
-: endif
-:endfunction
-:setlocal completefunc=DummyCompleteThree
-/^three
-A:/^+++/,/^three/w! test.out
-:qa!
-ENDTEST
-
-+++
-one
-two
-three
diff --git a/src/testdir/test76.ok b/src/testdir/test76.ok
deleted file mode 100644
index 2a70acbad..000000000
--- a/src/testdir/test76.ok
+++ /dev/null
@@ -1,4 +0,0 @@
-+++
-
-two
-threeDEF
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index 10eaf3a63..7cb0e10aa 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -289,4 +289,115 @@ func Test_compl_vim_cmds_after_register_expr()
bwipe!
endfunc
+func DummyCompleteOne(findstart, base)
+ if a:findstart
+ return 0
+ else
+ wincmd n
+ return ['onedef', 'oneDEF']
+ endif
+endfunc
+
+" Test that nothing happens if the 'completefunc' opens
+" a new window (no completion, no crash)
+func Test_completefunc_opens_new_window_one()
+ new
+ let winid = win_getid()
+ setlocal completefunc=DummyCompleteOne
+ call setline(1, 'one')
+ /^one
+ call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E839:')
+ call assert_notequal(winid, win_getid())
+ q!
+ call assert_equal(winid, win_getid())
+ call assert_equal('', getline(1))
+ q!
+endfunc
+
+" Test that nothing happens if the 'completefunc' opens
+" a new window (no completion, no crash)
+func DummyCompleteTwo(findstart, base)
+ if a:findstart
+ wincmd n
+ return 0
+ else
+ return ['twodef', 'twoDEF']
+ endif
+endfunction
+
+" Test that nothing happens if the 'completefunc' opens
+" a new window (no completion, no crash)
+func Test_completefunc_opens_new_window_two()
+ new
+ let winid = win_getid()
+ setlocal completefunc=DummyCompleteTwo
+ call setline(1, 'two')
+ /^two
+ call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E764:')
+ call assert_notequal(winid, win_getid())
+ q!
+ call assert_equal(winid, win_getid())
+ call assert_equal('two', getline(1))
+ q!
+endfunc
+
+func DummyCompleteThree(findstart, base)
+ if a:findstart
+ return 0
+ else
+ return ['threedef', 'threeDEF']
+ endif
+endfunc
+
+:"Test that 'completefunc' works when it's OK.
+func Test_completefunc_works()
+ new
+ let winid = win_getid()
+ setlocal completefunc=DummyCompleteThree
+ call setline(1, 'three')
+ /^three
+ call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")
+ call assert_equal(winid, win_getid())
+ call assert_equal('threeDEF', getline(1))
+ q!
+endfunc
+
+func DummyCompleteFour(findstart, base)
+ if a:findstart
+ return 0
+ else
+ call complete_add('four1')
+ call complete_add('four2')
+ call complete_check()
+ call complete_add('four3')
+ call complete_add('four4')
+ call complete_check()
+ call complete_add('four5')
+ call complete_add('four6')
+ return []
+ endif
+endfunc
+
+:"Test that 'completefunc' works when it's OK.
+func Test_omnifunc_with_check()
+ new
+ setlocal omnifunc=DummyCompleteFour
+ call setline(1, 'four')
+ /^four
+ call feedkeys("A\<C-X>\<C-O>\<C-N>\<Esc>", "x")
+ call assert_equal('four2', getline(1))
+
+ call setline(1, 'four')
+ /^four
+ call feedkeys("A\<C-X>\<C-O>\<C-N>\<C-N>\<Esc>", "x")
+ call assert_equal('four3', getline(1))
+
+ call setline(1, 'four')
+ /^four
+ call feedkeys("A\<C-X>\<C-O>\<C-N>\<C-N>\<C-N>\<C-N>\<Esc>", "x")
+ call assert_equal('four5', getline(1))
+
+ q!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab