diff options
Diffstat (limited to 'src/testdir/test_ins_complete.vim')
-rw-r--r-- | src/testdir/test_ins_complete.vim | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 48589ce..aee3393 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -2586,9 +2586,85 @@ func Test_complete_fuzzy_match() call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!') call assert_equal('hello help hero h', getline('.')) + set completeopt-=noinsert + call setline(1, ['xyz yxz x']) + call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!') + call assert_equal('xyz yxz xyz', getline('.')) + " can fuzzy get yxz when use Ctrl-N twice + call setline(1, ['xyz yxz x']) + call feedkeys("A\<C-X>\<C-N>\<C-N>\<Esc>0", 'tx!') + call assert_equal('xyz yxz yxz', getline('.')) + + call setline(1, ['你好 你']) + call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!') + call assert_equal('你好 你好', getline('.')) + call setline(1, ['你的 我的 的']) + call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!') + call assert_equal('你的 我的 你的', getline('.')) + " can fuzzy get multiple-byte word when use Ctrl-N twice + call setline(1, ['你的 我的 的']) + call feedkeys("A\<C-X>\<C-N>\<C-N>\<Esc>0", 'tx!') + call assert_equal('你的 我的 我的', getline('.')) + + " respect wrapscan + set nowrapscan + call setline(1, ["xyz", "yxz", ""]) + call cursor(3, 1) + call feedkeys("Sy\<C-X>\<C-N>\<Esc>0", 'tx!') + call assert_equal('y', getline('.')) + set wrapscan + call feedkeys("Sy\<C-X>\<C-N>\<Esc>0", 'tx!') + call assert_equal('xyz', getline('.')) + + " fuzzy on file + call writefile([''], 'fobar', 'D') + call writefile([''], 'foobar', 'D') + call setline(1, ['fob']) + call cursor(1, 1) + call feedkeys("A\<C-X>\<C-f>\<Esc>0", 'tx!') + call assert_equal('fobar', getline('.')) + call feedkeys("Sfob\<C-X>\<C-f>\<C-N>\<Esc>0", 'tx!') + call assert_equal('foobar', getline('.')) + call feedkeys("S../\<C-X>\<C-f>\<Esc>0", 'tx!') + call assert_match('../*', getline('.')) + call feedkeys("S../td\<C-X>\<C-f>\<Esc>0", 'tx!') + call assert_match('../testdir', getline('.')) + + " can get completion from other buffer + set completeopt=fuzzy,menu,menuone + vnew + call setline(1, ["completeness,", "compatibility", "Composite", "Omnipotent"]) + wincmd p + call feedkeys("Somp\<C-N>\<Esc>0", 'tx!') + call assert_equal('completeness', getline('.')) + call feedkeys("Somp\<C-N>\<C-N>\<Esc>0", 'tx!') + call assert_equal('compatibility', getline('.')) + call feedkeys("Somp\<C-P>\<Esc>0", 'tx!') + call assert_equal('Omnipotent', getline('.')) + call feedkeys("Somp\<C-P>\<C-P>\<Esc>0", 'tx!') + call assert_equal('Composite', getline('.')) + call feedkeys("S omp\<C-N>\<Esc>0", 'tx!') + call assert_equal(' completeness', getline('.')) + + " fuzzy on whole line completion + call setline(1, ["world is on fire", "no one can save me but you", 'user can execute', '']) + call cursor(4, 1) + call feedkeys("Swio\<C-X>\<C-L>\<Esc>0", 'tx!') + call assert_equal('world is on fire', getline('.')) + call feedkeys("Su\<C-X>\<C-L>\<C-P>\<Esc>0", 'tx!') + call assert_equal('no one can save me but you', getline('.')) + + " issue #15526 + set completeopt=fuzzy,menuone,menu,noselect + call setline(1, ['Text', 'ToText', '']) + call cursor(2, 1) + call feedkeys("STe\<C-X>\<C-N>x\<CR>\<Esc>0", 'tx!') + call assert_equal('Tex', getline('.')) + " clean up set omnifunc= bw! + bw! set complete& completeopt& autocmd! AAAAA_Group augroup! AAAAA_Group @@ -2599,6 +2675,38 @@ func Test_complete_fuzzy_match() unlet g:word endfunc +func Test_complete_fuzzy_with_completeslash() + CheckMSWindows + + call writefile([''], 'fobar', 'D') + let orig_shellslash = &shellslash + set cpt& + new + set completeopt+=fuzzy + set noshellslash + + " Test with completeslash unset + set completeslash= + call setline(1, ['.\fob']) + call feedkeys("A\<C-X>\<C-F>\<Esc>0", 'tx!') + call assert_equal('.\fobar', getline('.')) + + " Test with completeslash=backslash + set completeslash=backslash + call feedkeys("S.\\fob\<C-X>\<C-F>\<Esc>0", 'tx!') + call assert_equal('.\fobar', getline('.')) + + " Test with completeslash=slash + set completeslash=slash + call feedkeys("S.\\fob\<C-X>\<C-F>\<Esc>0", 'tx!') + call assert_equal('./fobar', getline('.')) + + " Reset and clean up + let &shellslash = orig_shellslash + set completeslash= + %bw! +endfunc + " Check that tie breaking is stable for completeopt+=fuzzy (which should " behave the same on different platforms). func Test_complete_fuzzy_match_tie() @@ -2619,4 +2727,14 @@ func Test_complete_fuzzy_match_tie() set completeopt& endfunc +func Test_complete_backwards_default() + new + call append(1, ['foobar', 'foobaz']) + new + call feedkeys("i\<c-p>", 'tx') + call assert_equal('foobaz', getline('.')) + bw! + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab nofoldenable |