2016-07-22 19:33:38 -07:00
|
|
|
" Tests for editing the command line.
|
|
|
|
|
2020-10-01 22:05:12 -07:00
|
|
|
source check.vim
|
|
|
|
source screendump.vim
|
|
|
|
|
2016-07-22 19:33:38 -07:00
|
|
|
func Test_complete_tab()
|
|
|
|
call writefile(['testfile'], 'Xtestfile')
|
2017-08-09 08:02:35 -07:00
|
|
|
call feedkeys(":e Xtestf\t\r", "tx")
|
2016-07-22 19:33:38 -07:00
|
|
|
call assert_equal('testfile', getline(1))
|
|
|
|
call delete('Xtestfile')
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func Test_complete_list()
|
|
|
|
" We can't see the output, but at least we check the code runs properly.
|
|
|
|
call feedkeys(":e test\<C-D>\r", "tx")
|
|
|
|
call assert_equal('test', expand('%:t'))
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func Test_complete_wildmenu()
|
2019-09-02 21:05:23 -07:00
|
|
|
call mkdir('Xdir1/Xdir2', 'p')
|
|
|
|
call writefile(['testfile1'], 'Xdir1/Xtestfile1')
|
|
|
|
call writefile(['testfile2'], 'Xdir1/Xtestfile2')
|
|
|
|
call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile3')
|
|
|
|
call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile4')
|
2016-07-22 19:33:38 -07:00
|
|
|
set wildmenu
|
2019-09-02 21:05:23 -07:00
|
|
|
|
|
|
|
" Pressing <Tab> completes, and moves to next files when pressing again.
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<Tab>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile1', getline(1))
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile2', getline(1))
|
|
|
|
|
|
|
|
" <S-Tab> is like <Tab> but begin with the last match and then go to
|
|
|
|
" previous.
|
|
|
|
call feedkeys(":e Xdir1/Xtest\<S-Tab>\<CR>", 'tx')
|
2016-07-22 19:33:38 -07:00
|
|
|
call assert_equal('testfile2', getline(1))
|
2019-09-02 21:05:23 -07:00
|
|
|
call feedkeys(":e Xdir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile1', getline(1))
|
|
|
|
|
|
|
|
" <Left>/<Right> to move to previous/next file.
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<Right>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile1', getline(1))
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile2', getline(1))
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile1', getline(1))
|
|
|
|
|
|
|
|
" <Up>/<Down> to go up/down directories.
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<Down>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile3', getline(1))
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile1', getline(1))
|
2016-07-22 19:33:38 -07:00
|
|
|
|
2020-12-26 11:09:52 -07:00
|
|
|
+ " <C-J>/<C-K> mappings to go up/down directories when 'wildcharm' is
|
|
|
|
" different than 'wildchar'.
|
|
|
|
set wildcharm=<C-Z>
|
|
|
|
cnoremap <C-J> <Down><C-Z>
|
|
|
|
cnoremap <C-K> <Up><C-Z>
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<C-J>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile3', getline(1))
|
|
|
|
call feedkeys(":e Xdir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx')
|
|
|
|
call assert_equal('testfile1', getline(1))
|
|
|
|
set wildcharm=0
|
|
|
|
cunmap <C-J>
|
|
|
|
cunmap <C-K>
|
|
|
|
|
2019-09-02 21:05:23 -07:00
|
|
|
" cleanup
|
|
|
|
%bwipe
|
|
|
|
call delete('Xdir1/Xdir2/Xtestfile4')
|
|
|
|
call delete('Xdir1/Xdir2/Xtestfile3')
|
|
|
|
call delete('Xdir1/Xtestfile2')
|
|
|
|
call delete('Xdir1/Xtestfile1')
|
|
|
|
call delete('Xdir1/Xdir2', 'd')
|
|
|
|
call delete('Xdir1', 'd')
|
2016-07-22 19:33:38 -07:00
|
|
|
set nowildmenu
|
|
|
|
endfunc
|
|
|
|
|
2018-01-15 04:41:29 -07:00
|
|
|
func Test_map_completion()
|
|
|
|
if !has('cmdline_compl')
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <unique> <silent>', getreg(':'))
|
|
|
|
call feedkeys(":map <script> <un\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <script> <unique>', getreg(':'))
|
|
|
|
call feedkeys(":map <expr> <sc\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <expr> <script>', getreg(':'))
|
|
|
|
call feedkeys(":map <buffer> <e\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <buffer> <expr>', getreg(':'))
|
|
|
|
call feedkeys(":map <nowait> <b\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <nowait> <buffer>', getreg(':'))
|
|
|
|
call feedkeys(":map <special> <no\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <special> <nowait>', getreg(':'))
|
|
|
|
call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <silent> <special>', getreg(':'))
|
2019-08-04 16:12:35 -07:00
|
|
|
|
2019-11-26 19:54:48 -07:00
|
|
|
map <Middle>x middle
|
|
|
|
|
2019-08-04 16:12:35 -07:00
|
|
|
map ,f commaf
|
|
|
|
map ,g commaf
|
2019-11-26 19:54:48 -07:00
|
|
|
map <Left> left
|
|
|
|
map <A-Left>x shiftleft
|
2019-08-04 16:12:35 -07:00
|
|
|
call feedkeys(":map ,\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map ,f', getreg(':'))
|
|
|
|
call feedkeys(":map ,\<Tab>\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map ,g', getreg(':'))
|
2019-11-26 19:54:48 -07:00
|
|
|
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <Left>', getreg(':'))
|
|
|
|
call feedkeys(":map <A-Left>\<Tab>\<Home>\"\<CR>", 'xt')
|
2019-11-26 20:02:26 -07:00
|
|
|
call assert_equal("\"map <A-Left>\<Tab>", getreg(':'))
|
2019-08-04 16:12:35 -07:00
|
|
|
unmap ,f
|
|
|
|
unmap ,g
|
2019-11-26 19:54:48 -07:00
|
|
|
unmap <Left>
|
|
|
|
unmap <A-Left>x
|
2019-08-04 16:12:35 -07:00
|
|
|
|
|
|
|
set cpo-=< cpo-=B cpo-=k
|
|
|
|
map <Left> left
|
|
|
|
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <Left>', getreg(':'))
|
2019-11-26 19:54:48 -07:00
|
|
|
call feedkeys(":map <M\<Tab>\<Home>\"\<CR>", 'xt')
|
2019-11-26 20:02:26 -07:00
|
|
|
" call assert_equal("\"map <M\<Tab>", getreg(':'))
|
2019-08-04 16:12:35 -07:00
|
|
|
unmap <Left>
|
|
|
|
|
|
|
|
" set cpo+=<
|
|
|
|
map <Left> left
|
2019-11-26 20:06:31 -07:00
|
|
|
exe "set t_k6=\<Esc>[17~"
|
|
|
|
call feedkeys(":map \<Esc>[17~x f6x\<CR>", 'xt')
|
2019-08-04 16:12:35 -07:00
|
|
|
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <Left>', getreg(':'))
|
2019-11-26 20:08:31 -07:00
|
|
|
if !has('gui_running')
|
|
|
|
call feedkeys(":map \<Esc>[17~\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
" call assert_equal("\"map <F6>x", getreg(':'))
|
|
|
|
endif
|
2019-08-04 16:12:35 -07:00
|
|
|
unmap <Left>
|
2019-11-26 20:06:31 -07:00
|
|
|
call feedkeys(":unmap \<Esc>[17~x\<CR>", 'xt')
|
2019-08-04 16:12:35 -07:00
|
|
|
set cpo-=<
|
|
|
|
|
|
|
|
set cpo+=B
|
|
|
|
map <Left> left
|
|
|
|
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <Left>', getreg(':'))
|
|
|
|
unmap <Left>
|
|
|
|
set cpo-=B
|
|
|
|
|
|
|
|
" set cpo+=k
|
|
|
|
map <Left> left
|
|
|
|
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"map <Left>', getreg(':'))
|
|
|
|
unmap <Left>
|
|
|
|
" set cpo-=k
|
2019-11-26 19:54:48 -07:00
|
|
|
|
|
|
|
unmap <Middle>x
|
|
|
|
set cpo&vim
|
2018-01-15 04:41:29 -07:00
|
|
|
endfunc
|
|
|
|
|
2018-02-15 07:50:41 -07:00
|
|
|
func Test_match_completion()
|
|
|
|
if !has('cmdline_compl')
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
hi Aardig ctermfg=green
|
|
|
|
call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"match Aardig', getreg(':'))
|
|
|
|
call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"match none', getreg(':'))
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func Test_highlight_completion()
|
|
|
|
if !has('cmdline_compl')
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
hi Aardig ctermfg=green
|
|
|
|
call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"hi Aardig', getreg(':'))
|
2018-06-02 05:21:39 -07:00
|
|
|
call feedkeys(":hi default \<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"hi default Aardig', getreg(':'))
|
|
|
|
call feedkeys(":hi clear Aa\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"hi clear Aardig', getreg(':'))
|
2018-02-15 07:50:41 -07:00
|
|
|
call feedkeys(":hi li\<S-Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"hi link', getreg(':'))
|
|
|
|
call feedkeys(":hi d\<S-Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"hi default', getreg(':'))
|
|
|
|
call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"hi clear', getreg(':'))
|
2018-03-08 11:49:21 -07:00
|
|
|
|
|
|
|
" A cleared group does not show up in completions.
|
|
|
|
hi Anders ctermfg=green
|
|
|
|
call assert_equal(['Aardig', 'Anders'], getcompletion('A', 'highlight'))
|
|
|
|
hi clear Aardig
|
|
|
|
call assert_equal(['Anders'], getcompletion('A', 'highlight'))
|
|
|
|
hi clear Anders
|
|
|
|
call assert_equal([], getcompletion('A', 'highlight'))
|
2018-02-15 07:50:41 -07:00
|
|
|
endfunc
|
|
|
|
|
2017-11-10 15:35:55 -07:00
|
|
|
func Test_expr_completion()
|
2018-02-15 07:50:41 -07:00
|
|
|
if !has('cmdline_compl')
|
2017-11-10 15:35:55 -07:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
for cmd in [
|
|
|
|
\ 'let a = ',
|
2019-11-26 18:05:52 -07:00
|
|
|
\ 'const a = ',
|
2017-11-10 15:35:55 -07:00
|
|
|
\ 'if',
|
|
|
|
\ 'elseif',
|
|
|
|
\ 'while',
|
|
|
|
\ 'for',
|
|
|
|
\ 'echo',
|
|
|
|
\ 'echon',
|
|
|
|
\ 'execute',
|
|
|
|
\ 'echomsg',
|
|
|
|
\ 'echoerr',
|
|
|
|
\ 'call',
|
|
|
|
\ 'return',
|
|
|
|
\ 'cexpr',
|
|
|
|
\ 'caddexpr',
|
|
|
|
\ 'cgetexpr',
|
|
|
|
\ 'lexpr',
|
|
|
|
\ 'laddexpr',
|
|
|
|
\ 'lgetexpr']
|
|
|
|
call feedkeys(":" . cmd . " getl\<Tab>\<Home>\"\<CR>", 'xt')
|
|
|
|
call assert_equal('"' . cmd . ' getline(', getreg(':'))
|
|
|
|
endfor
|
|
|
|
endfunc
|
|
|
|
|
2016-07-22 19:33:38 -07:00
|
|
|
func Test_getcompletion()
|
|
|
|
if !has('cmdline_compl')
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
let groupcount = len(getcompletion('', 'event'))
|
|
|
|
call assert_true(groupcount > 0)
|
|
|
|
let matchcount = len(getcompletion('File', 'event'))
|
|
|
|
call assert_true(matchcount > 0)
|
|
|
|
call assert_true(groupcount > matchcount)
|
|
|
|
|
|
|
|
if has('menu')
|
|
|
|
source $VIMRUNTIME/menu.vim
|
|
|
|
let matchcount = len(getcompletion('', 'menu'))
|
|
|
|
call assert_true(matchcount > 0)
|
|
|
|
call assert_equal(['File.'], getcompletion('File', 'menu'))
|
|
|
|
call assert_true(matchcount > 0)
|
|
|
|
let matchcount = len(getcompletion('File.', 'menu'))
|
|
|
|
call assert_true(matchcount > 0)
|
|
|
|
endif
|
|
|
|
|
|
|
|
let l = getcompletion('v:n', 'var')
|
|
|
|
call assert_true(index(l, 'v:null') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('v:notexists', 'var')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
2018-08-16 08:28:05 -07:00
|
|
|
args a.c b.c
|
|
|
|
let l = getcompletion('', 'arglist')
|
|
|
|
call assert_equal(['a.c', 'b.c'], l)
|
|
|
|
%argdelete
|
|
|
|
|
2016-07-22 19:33:38 -07:00
|
|
|
let l = getcompletion('', 'augroup')
|
|
|
|
call assert_true(index(l, 'END') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('blahblah', 'augroup')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('', 'behave')
|
|
|
|
call assert_true(index(l, 'mswin') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('not', 'behave')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('', 'color')
|
|
|
|
call assert_true(index(l, 'default') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('dirty', 'color')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('', 'command')
|
|
|
|
call assert_true(index(l, 'sleep') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('awake', 'command')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('', 'dir')
|
2018-03-27 23:37:41 -07:00
|
|
|
call assert_true(index(l, expand('sautest/')) >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('NoMatch', 'dir')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('exe', 'expression')
|
|
|
|
call assert_true(index(l, 'executable(') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('kill', 'expression')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('tag', 'function')
|
|
|
|
call assert_true(index(l, 'taglist(') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('paint', 'function')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
2016-12-15 12:48:41 -07:00
|
|
|
let Flambda = {-> 'hello'}
|
|
|
|
let l = getcompletion('', 'function')
|
|
|
|
let l = filter(l, {i, v -> v =~ 'lambda'})
|
|
|
|
call assert_equal(0, len(l))
|
|
|
|
|
2016-07-22 19:33:38 -07:00
|
|
|
let l = getcompletion('run', 'file')
|
|
|
|
call assert_true(index(l, 'runtest.vim') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('walk', 'file')
|
|
|
|
call assert_equal([], l)
|
2016-10-01 03:54:59 -07:00
|
|
|
set wildignore=*.vim
|
|
|
|
let l = getcompletion('run', 'file', 1)
|
|
|
|
call assert_true(index(l, 'runtest.vim') < 0)
|
|
|
|
set wildignore&
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('ha', 'filetype')
|
|
|
|
call assert_true(index(l, 'hamster') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('horse', 'filetype')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('z', 'syntax')
|
|
|
|
call assert_true(index(l, 'zimbu') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('emacs', 'syntax')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('jikes', 'compiler')
|
|
|
|
call assert_true(index(l, 'jikes') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('break', 'compiler')
|
|
|
|
call assert_equal([], l)
|
|
|
|
|
|
|
|
let l = getcompletion('last', 'help')
|
|
|
|
call assert_true(index(l, ':tablast') >= 0)
|
|
|
|
let l = getcompletion('giveup', 'help')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('time', 'option')
|
|
|
|
call assert_true(index(l, 'timeoutlen') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('space', 'option')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
let l = getcompletion('er', 'highlight')
|
|
|
|
call assert_true(index(l, 'ErrorMsg') >= 0)
|
2016-08-17 06:24:20 -07:00
|
|
|
let l = getcompletion('dark', 'highlight')
|
|
|
|
call assert_equal([], l)
|
2016-07-22 19:33:38 -07:00
|
|
|
|
2017-07-25 09:30:28 -07:00
|
|
|
let l = getcompletion('', 'messages')
|
|
|
|
call assert_true(index(l, 'clear') >= 0)
|
|
|
|
let l = getcompletion('not', 'messages')
|
|
|
|
call assert_equal([], l)
|
|
|
|
|
2018-08-16 07:24:49 -07:00
|
|
|
let l = getcompletion('', 'mapclear')
|
|
|
|
call assert_true(index(l, '<buffer>') >= 0)
|
|
|
|
let l = getcompletion('not', 'mapclear')
|
|
|
|
call assert_equal([], l)
|
|
|
|
|
2019-07-28 16:25:54 -07:00
|
|
|
let l = getcompletion('.', 'shellcmd')
|
2019-11-24 22:34:52 -07:00
|
|
|
call assert_equal(['./', '../'], filter(l, 'v:val =~ "\\./"'))
|
2019-07-28 16:25:54 -07:00
|
|
|
call assert_equal(-1, match(l[2:], '^\.\.\?/$'))
|
|
|
|
let root = has('win32') ? 'C:\\' : '/'
|
|
|
|
let l = getcompletion(root, 'shellcmd')
|
|
|
|
let expected = map(filter(glob(root . '*', 0, 1),
|
|
|
|
\ 'isdirectory(v:val) || executable(v:val)'), 'isdirectory(v:val) ? v:val . ''/'' : v:val')
|
|
|
|
call assert_equal(expected, l)
|
|
|
|
|
2016-10-01 03:38:34 -07:00
|
|
|
if has('cscope')
|
|
|
|
let l = getcompletion('', 'cscope')
|
|
|
|
let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show']
|
|
|
|
call assert_equal(cmds, l)
|
|
|
|
" using cmdline completion must not change the result
|
|
|
|
call feedkeys(":cscope find \<c-d>\<c-c>", 'xt')
|
|
|
|
let l = getcompletion('', 'cscope')
|
|
|
|
call assert_equal(cmds, l)
|
|
|
|
let keys = ['a', 'c', 'd', 'e', 'f', 'g', 'i', 's', 't']
|
|
|
|
let l = getcompletion('find ', 'cscope')
|
|
|
|
call assert_equal(keys, l)
|
|
|
|
endif
|
|
|
|
|
2016-10-01 03:41:48 -07:00
|
|
|
if has('signs')
|
|
|
|
sign define Testing linehl=Comment
|
|
|
|
let l = getcompletion('', 'sign')
|
|
|
|
let cmds = ['define', 'jump', 'list', 'place', 'undefine', 'unplace']
|
|
|
|
call assert_equal(cmds, l)
|
|
|
|
" using cmdline completion must not change the result
|
|
|
|
call feedkeys(":sign list \<c-d>\<c-c>", 'xt')
|
|
|
|
let l = getcompletion('', 'sign')
|
|
|
|
call assert_equal(cmds, l)
|
|
|
|
let l = getcompletion('list ', 'sign')
|
|
|
|
call assert_equal(['Testing'], l)
|
|
|
|
endif
|
|
|
|
|
2017-03-27 12:04:52 -07:00
|
|
|
" Command line completion tests
|
|
|
|
let l = getcompletion('cd ', 'cmdline')
|
2018-03-27 23:37:41 -07:00
|
|
|
call assert_true(index(l, expand('sautest/')) >= 0)
|
2017-03-27 12:04:52 -07:00
|
|
|
let l = getcompletion('cd NoMatch', 'cmdline')
|
|
|
|
call assert_equal([], l)
|
|
|
|
let l = getcompletion('let v:n', 'cmdline')
|
|
|
|
call assert_true(index(l, 'v:null') >= 0)
|
|
|
|
let l = getcompletion('let v:notexists', 'cmdline')
|
|
|
|
call assert_equal([], l)
|
|
|
|
let l = getcompletion('call tag', 'cmdline')
|
|
|
|
call assert_true(index(l, 'taglist(') >= 0)
|
|
|
|
let l = getcompletion('call paint', 'cmdline')
|
|
|
|
call assert_equal([], l)
|
|
|
|
|
2016-07-22 19:33:38 -07:00
|
|
|
" For others test if the name is recognized.
|
2019-07-28 16:25:54 -07:00
|
|
|
let names = ['buffer', 'environment', 'file_in_path', 'mapping', 'tag', 'tag_listfiles', 'user']
|
2016-07-22 19:33:38 -07:00
|
|
|
if has('cmdline_hist')
|
|
|
|
call add(names, 'history')
|
|
|
|
endif
|
|
|
|
if has('gettext')
|
|
|
|
call add(names, 'locale')
|
|
|
|
endif
|
|
|
|
if has('profile')
|
|
|
|
call add(names, 'syntime')
|
|
|
|
endif
|
|
|
|
|
|
|
|
set tags=Xtags
|
|
|
|
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags')
|
|
|
|
|
|
|
|
for name in names
|
|
|
|
let matchcount = len(getcompletion('', name))
|
|
|
|
call assert_true(matchcount >= 0, 'No matches for ' . name)
|
|
|
|
endfor
|
|
|
|
|
|
|
|
call delete('Xtags')
|
2019-06-16 05:31:58 -07:00
|
|
|
set tags&
|
2016-07-22 19:33:38 -07:00
|
|
|
|
|
|
|
call assert_fails('call getcompletion("", "burp")', 'E475:')
|
|
|
|
endfunc
|
2016-10-12 14:01:11 -07:00
|
|
|
|
2019-11-24 22:34:52 -07:00
|
|
|
func Test_shellcmd_completion()
|
|
|
|
let save_path = $PATH
|
|
|
|
|
|
|
|
call mkdir('Xpathdir/Xpathsubdir', 'p')
|
|
|
|
call writefile([''], 'Xpathdir/Xfile.exe')
|
|
|
|
call setfperm('Xpathdir/Xfile.exe', 'rwx------')
|
|
|
|
|
|
|
|
" Set PATH to example directory without trailing slash.
|
|
|
|
let $PATH = getcwd() . '/Xpathdir'
|
|
|
|
|
|
|
|
" Test for the ":!<TAB>" case. Previously, this would include subdirs of
|
|
|
|
" dirs in the PATH, even though they won't be executed. We check that only
|
|
|
|
" subdirs of the PWD and executables from the PATH are included in the
|
|
|
|
" suggestions.
|
|
|
|
let actual = getcompletion('X', 'shellcmd')
|
|
|
|
let expected = map(filter(glob('*', 0, 1), 'isdirectory(v:val) && v:val[0] == "X"'), 'v:val . "/"')
|
|
|
|
call insert(expected, 'Xfile.exe')
|
|
|
|
call assert_equal(expected, actual)
|
|
|
|
|
|
|
|
call delete('Xpathdir', 'rf')
|
|
|
|
let $PATH = save_path
|
|
|
|
endfunc
|
|
|
|
|
2016-10-12 14:01:11 -07:00
|
|
|
func Test_expand_star_star()
|
|
|
|
call mkdir('a/b', 'p')
|
|
|
|
call writefile(['asdfasdf'], 'a/b/fileXname')
|
|
|
|
call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt')
|
2018-03-27 23:37:41 -07:00
|
|
|
call assert_equal('find '.expand('a/b/fileXname'), getreg(':'))
|
2017-03-29 07:48:50 -07:00
|
|
|
bwipe!
|
2016-10-12 14:01:11 -07:00
|
|
|
call delete('a', 'rf')
|
|
|
|
endfunc
|
2017-07-29 16:36:44 -07:00
|
|
|
|
|
|
|
func Test_paste_in_cmdline()
|
|
|
|
let @a = "def"
|
|
|
|
call feedkeys(":abc \<C-R>a ghi\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"abc def ghi', @:)
|
|
|
|
|
|
|
|
new
|
|
|
|
call setline(1, 'asdf.x /tmp/some verylongword a;b-c*d ')
|
|
|
|
|
|
|
|
call feedkeys(":aaa \<C-R>\<C-W> bbb\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"aaa asdf bbb', @:)
|
|
|
|
|
|
|
|
call feedkeys("ft:aaa \<C-R>\<C-F> bbb\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"aaa /tmp/some bbb', @:)
|
|
|
|
|
2018-08-16 18:25:33 -07:00
|
|
|
call feedkeys(":aaa \<C-R>\<C-L> bbb\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"aaa '.getline(1).' bbb', @:)
|
|
|
|
|
2017-07-29 16:36:44 -07:00
|
|
|
set incsearch
|
|
|
|
call feedkeys("fy:aaa veryl\<C-R>\<C-W> bbb\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"aaa verylongword bbb', @:)
|
|
|
|
|
|
|
|
call feedkeys("f;:aaa \<C-R>\<C-A> bbb\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"aaa a;b-c*d bbb', @:)
|
2017-09-03 06:23:09 -07:00
|
|
|
|
|
|
|
call feedkeys(":\<C-\>etoupper(getline(1))\<CR>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"ASDF.X /TMP/SOME VERYLONGWORD A;B-C*D ', @:)
|
2017-07-29 16:36:44 -07:00
|
|
|
bwipe!
|
2018-10-13 18:43:43 -07:00
|
|
|
|
|
|
|
" Error while typing a command used to cause that it was not executed
|
|
|
|
" in the end.
|
|
|
|
new
|
|
|
|
try
|
|
|
|
call feedkeys(":file \<C-R>%Xtestfile\<CR>", 'tx')
|
|
|
|
catch /^Vim\%((\a\+)\)\=:E32/
|
|
|
|
" ignore error E32
|
|
|
|
endtry
|
|
|
|
call assert_equal("Xtestfile", bufname("%"))
|
|
|
|
bwipe!
|
2017-07-29 16:36:44 -07:00
|
|
|
endfunc
|
2017-08-02 01:22:04 -07:00
|
|
|
|
2017-09-03 06:23:09 -07:00
|
|
|
func Test_remove_char_in_cmdline()
|
2018-02-15 07:50:41 -07:00
|
|
|
call feedkeys(":abc def\<S-Left>\<Del>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"abc ef', @:)
|
2017-09-03 06:23:09 -07:00
|
|
|
|
2018-02-15 07:50:41 -07:00
|
|
|
call feedkeys(":abc def\<S-Left>\<BS>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"abcdef', @:)
|
2017-09-03 06:23:09 -07:00
|
|
|
|
2018-02-15 07:50:41 -07:00
|
|
|
call feedkeys(":abc def ghi\<S-Left>\<C-W>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"abc ghi', @:)
|
2017-09-03 06:23:09 -07:00
|
|
|
|
2018-02-15 07:50:41 -07:00
|
|
|
call feedkeys(":abc def\<S-Left>\<C-U>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"def', @:)
|
2017-09-03 06:23:09 -07:00
|
|
|
endfunc
|
|
|
|
|
2017-09-17 11:04:17 -07:00
|
|
|
func Test_illegal_address1()
|
2017-08-02 01:22:04 -07:00
|
|
|
new
|
|
|
|
2;'(
|
|
|
|
2;')
|
|
|
|
quit
|
|
|
|
endfunc
|
2017-09-17 11:04:17 -07:00
|
|
|
|
|
|
|
func Test_illegal_address2()
|
|
|
|
call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim')
|
|
|
|
new
|
|
|
|
source Xtest.vim
|
|
|
|
" Trigger calling validate_cursor()
|
|
|
|
diffsp Xtest.vim
|
|
|
|
quit!
|
|
|
|
bwipe!
|
|
|
|
call delete('Xtest.vim')
|
|
|
|
endfunc
|
|
|
|
|
2017-11-10 17:26:55 -07:00
|
|
|
func Test_cmdline_complete_wildoptions()
|
|
|
|
help
|
|
|
|
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')
|
|
|
|
let a = join(sort(split(@:)),' ')
|
|
|
|
set wildoptions=tagfile
|
|
|
|
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')
|
|
|
|
let b = join(sort(split(@:)),' ')
|
|
|
|
call assert_equal(a, b)
|
|
|
|
bw!
|
|
|
|
endfunc
|
2017-12-02 00:25:24 -07:00
|
|
|
|
2018-06-08 15:20:09 -07:00
|
|
|
func Test_cmdline_complete_user_cmd()
|
|
|
|
command! -complete=color -nargs=1 Foo :
|
|
|
|
call feedkeys(":Foo \<Tab>\<Home>\"\<cr>", 'tx')
|
|
|
|
call assert_equal('"Foo blue', @:)
|
|
|
|
call feedkeys(":Foo b\<Tab>\<Home>\"\<cr>", 'tx')
|
|
|
|
call assert_equal('"Foo blue', @:)
|
|
|
|
delcommand Foo
|
|
|
|
endfunc
|
|
|
|
|
2019-10-13 01:48:01 -07:00
|
|
|
func Test_cmdline_complete_user_names()
|
|
|
|
if has('unix') && executable('whoami')
|
|
|
|
let whoami = systemlist('whoami')[0]
|
|
|
|
let first_letter = whoami[0]
|
|
|
|
if len(first_letter) > 0
|
|
|
|
" Trying completion of :e ~x where x is the first letter of
|
|
|
|
" the user name should complete to at least the user name.
|
|
|
|
call feedkeys(':e ~' . first_letter . "\<c-a>\<c-B>\"\<cr>", 'tx')
|
|
|
|
call assert_match('^"e \~.*\<' . whoami . '\>', @:)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
if has('win32')
|
|
|
|
" Just in case: check that the system has an Administrator account.
|
|
|
|
let names = system('net user')
|
|
|
|
if names =~ 'Administrator'
|
|
|
|
" Trying completion of :e ~A should complete to Administrator.
|
2019-11-24 22:43:28 -07:00
|
|
|
" There could be other names starting with "A" before Administrator.
|
2019-10-13 01:48:01 -07:00
|
|
|
call feedkeys(':e ~A' . "\<c-a>\<c-B>\"\<cr>", 'tx')
|
2019-11-24 22:43:28 -07:00
|
|
|
call assert_match('^"e \~.*Administrator', @:)
|
2019-10-13 01:48:01 -07:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfunc
|
|
|
|
|
2020-12-24 20:00:23 -07:00
|
|
|
func Test_cmdline_complete_bang()
|
|
|
|
if executable('whoami')
|
|
|
|
call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_match('^".*\<whoami\>', @:)
|
|
|
|
endif
|
|
|
|
endfunc
|
|
|
|
|
2019-10-13 01:48:01 -07:00
|
|
|
funct Test_cmdline_complete_languages()
|
|
|
|
let lang = substitute(execute('language messages'), '.*"\(.*\)"$', '\1', '')
|
|
|
|
|
|
|
|
call feedkeys(":language \<c-a>\<c-b>\"\<cr>", 'tx')
|
|
|
|
call assert_match('^"language .*\<ctype\>.*\<messages\>.*\<time\>', @:)
|
|
|
|
|
|
|
|
if has('unix')
|
|
|
|
" TODO: these tests don't work on Windows. lang appears to be 'C'
|
|
|
|
" but C does not appear in the completion. Why?
|
|
|
|
call assert_match('^"language .*\<' . lang . '\>', @:)
|
|
|
|
|
|
|
|
call feedkeys(":language messages \<c-a>\<c-b>\"\<cr>", 'tx')
|
|
|
|
call assert_match('^"language .*\<' . lang . '\>', @:)
|
|
|
|
|
|
|
|
call feedkeys(":language ctype \<c-a>\<c-b>\"\<cr>", 'tx')
|
|
|
|
call assert_match('^"language .*\<' . lang . '\>', @:)
|
|
|
|
|
|
|
|
call feedkeys(":language time \<c-a>\<c-b>\"\<cr>", 'tx')
|
|
|
|
call assert_match('^"language .*\<' . lang . '\>', @:)
|
|
|
|
endif
|
|
|
|
endfunc
|
|
|
|
|
2020-12-24 15:18:25 -07:00
|
|
|
func Test_cmdline_complete_expression()
|
|
|
|
let g:SomeVar = 'blah'
|
|
|
|
for cmd in ['exe', 'echo', 'echon', 'echomsg']
|
|
|
|
call feedkeys(":" .. cmd .. " SomeV\<Tab>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_match('"' .. cmd .. ' SomeVar', @:)
|
|
|
|
call feedkeys(":" .. cmd .. " foo SomeV\<Tab>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_match('"' .. cmd .. ' foo SomeVar', @:)
|
|
|
|
endfor
|
|
|
|
unlet g:SomeVar
|
|
|
|
endfunc
|
|
|
|
|
2018-08-16 08:03:12 -07:00
|
|
|
func Test_cmdline_write_alternatefile()
|
|
|
|
new
|
|
|
|
call setline('.', ['one', 'two'])
|
|
|
|
f foo.txt
|
|
|
|
new
|
|
|
|
f #-A
|
|
|
|
call assert_equal('foo.txt-A', expand('%'))
|
|
|
|
f #<-B.txt
|
|
|
|
call assert_equal('foo-B.txt', expand('%'))
|
|
|
|
f %<
|
|
|
|
call assert_equal('foo-B', expand('%'))
|
|
|
|
new
|
|
|
|
call assert_fails('f #<', 'E95')
|
|
|
|
bw!
|
|
|
|
f foo-B.txt
|
|
|
|
f %<-A
|
|
|
|
call assert_equal('foo-B-A', expand('%'))
|
|
|
|
bw!
|
|
|
|
bw!
|
|
|
|
endfunc
|
|
|
|
|
2017-12-02 00:25:24 -07:00
|
|
|
" using a leading backslash here
|
|
|
|
set cpo+=C
|
|
|
|
|
|
|
|
func Test_cmdline_search_range()
|
|
|
|
new
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
/d
|
|
|
|
1,\/s/b/B/
|
|
|
|
call assert_equal('B', getline(2))
|
|
|
|
|
|
|
|
/a
|
|
|
|
$
|
|
|
|
\?,4s/c/C/
|
|
|
|
call assert_equal('C', getline(3))
|
|
|
|
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
%s/c/c/
|
|
|
|
1,\&s/b/B/
|
|
|
|
call assert_equal('B', getline(2))
|
|
|
|
|
|
|
|
bwipe!
|
|
|
|
endfunc
|
|
|
|
|
2017-12-21 03:31:26 -07:00
|
|
|
" Tests for getcmdline(), getcmdpos() and getcmdtype()
|
|
|
|
func Check_cmdline(cmdtype)
|
|
|
|
call assert_equal('MyCmd a', getcmdline())
|
|
|
|
call assert_equal(8, getcmdpos())
|
|
|
|
call assert_equal(a:cmdtype, getcmdtype())
|
|
|
|
return ''
|
|
|
|
endfunc
|
|
|
|
|
2019-11-29 10:51:25 -07:00
|
|
|
set cpo&
|
|
|
|
|
2017-12-21 03:31:26 -07:00
|
|
|
func Test_getcmdtype()
|
|
|
|
call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt")
|
|
|
|
|
|
|
|
let cmdtype = ''
|
|
|
|
debuggreedy
|
|
|
|
call feedkeys(":debug echo 'test'\<CR>", "t")
|
|
|
|
call feedkeys("let cmdtype = \<C-R>=string(getcmdtype())\<CR>\<CR>", "t")
|
|
|
|
call feedkeys("cont\<CR>", "xt")
|
|
|
|
0debuggreedy
|
|
|
|
call assert_equal('>', cmdtype)
|
|
|
|
|
|
|
|
call feedkeys("/MyCmd a\<C-R>=Check_cmdline('/')\<CR>\<Esc>", "xt")
|
|
|
|
call feedkeys("?MyCmd a\<C-R>=Check_cmdline('?')\<CR>\<Esc>", "xt")
|
|
|
|
|
|
|
|
call feedkeys(":call input('Answer?')\<CR>", "t")
|
2018-02-16 04:04:06 -07:00
|
|
|
call feedkeys("MyCmd a\<C-R>=Check_cmdline('@')\<CR>\<C-C>", "xt")
|
2017-12-21 03:31:26 -07:00
|
|
|
|
|
|
|
call feedkeys(":insert\<CR>MyCmd a\<C-R>=Check_cmdline('-')\<CR>\<Esc>", "xt")
|
|
|
|
|
|
|
|
cnoremap <expr> <F6> Check_cmdline('=')
|
|
|
|
call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt")
|
|
|
|
cunmap <F6>
|
|
|
|
endfunc
|
|
|
|
|
2018-08-16 09:56:14 -07:00
|
|
|
func Test_getcmdwintype()
|
|
|
|
call feedkeys("q/:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
|
|
|
|
call assert_equal('/', a)
|
|
|
|
|
|
|
|
call feedkeys("q?:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
|
|
|
|
call assert_equal('?', a)
|
|
|
|
|
|
|
|
call feedkeys("q::let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
|
|
|
|
call assert_equal(':', a)
|
|
|
|
|
|
|
|
call feedkeys(":\<C-F>:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
|
|
|
|
call assert_equal(':', a)
|
|
|
|
|
|
|
|
call assert_equal('', getcmdwintype())
|
|
|
|
endfunc
|
|
|
|
|
2019-11-29 10:51:25 -07:00
|
|
|
func Test_getcmdwin_autocmd()
|
|
|
|
let s:seq = []
|
|
|
|
augroup CmdWin
|
|
|
|
au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid())
|
|
|
|
au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid())
|
|
|
|
au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr())
|
|
|
|
au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr())
|
|
|
|
au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid())
|
|
|
|
au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid())
|
|
|
|
|
|
|
|
let org_winid = win_getid()
|
|
|
|
let org_bufnr = bufnr()
|
|
|
|
call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!')
|
|
|
|
call assert_equal(':', a)
|
|
|
|
call assert_equal([
|
|
|
|
\ 'WinLeave ' .. org_winid,
|
|
|
|
\ 'WinEnter ' .. s:cmd_winid,
|
|
|
|
\ 'BufLeave ' .. org_bufnr,
|
|
|
|
\ 'BufEnter ' .. s:cmd_bufnr,
|
|
|
|
\ 'CmdWinEnter ' .. s:cmd_winid,
|
|
|
|
\ 'CmdWinLeave ' .. s:cmd_winid,
|
|
|
|
\ 'BufLeave ' .. s:cmd_bufnr,
|
|
|
|
\ 'WinLeave ' .. s:cmd_winid,
|
|
|
|
\ 'WinEnter ' .. org_winid,
|
|
|
|
\ 'BufEnter ' .. org_bufnr,
|
|
|
|
\ ], s:seq)
|
|
|
|
|
|
|
|
au!
|
|
|
|
augroup END
|
|
|
|
endfunc
|
|
|
|
|
2020-06-04 18:08:33 -07:00
|
|
|
" Test error: "E135: *Filter* Autocommands must not change current buffer"
|
|
|
|
func Test_cmd_bang_E135()
|
|
|
|
new
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
augroup test_cmd_filter_E135
|
|
|
|
au!
|
|
|
|
autocmd FilterReadPost * help
|
|
|
|
augroup END
|
|
|
|
call assert_fails('2,3!echo "x"', 'E135:')
|
|
|
|
|
|
|
|
augroup test_cmd_filter_E135
|
|
|
|
au!
|
|
|
|
augroup END
|
|
|
|
%bwipe!
|
|
|
|
endfunc
|
|
|
|
|
2018-06-18 05:37:52 -07:00
|
|
|
func Test_verbosefile()
|
|
|
|
set verbosefile=Xlog
|
|
|
|
echomsg 'foo'
|
|
|
|
echomsg 'bar'
|
|
|
|
set verbosefile=
|
|
|
|
let log = readfile('Xlog')
|
|
|
|
call assert_match("foo\nbar", join(log, "\n"))
|
|
|
|
call delete('Xlog')
|
|
|
|
endfunc
|
|
|
|
|
2020-10-01 22:05:12 -07:00
|
|
|
func Test_verbose_option()
|
2020-10-27 20:52:02 -07:00
|
|
|
" See test/functional/legacy/cmdline_spec.lua
|
2020-10-01 22:05:12 -07:00
|
|
|
CheckScreendump
|
|
|
|
|
|
|
|
let lines =<< trim [SCRIPT]
|
|
|
|
command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v
|
|
|
|
call feedkeys("\r", 't') " for the hit-enter prompt
|
|
|
|
set verbose=20
|
|
|
|
[SCRIPT]
|
|
|
|
call writefile(lines, 'XTest_verbose')
|
|
|
|
|
|
|
|
let buf = RunVimInTerminal('-S XTest_verbose', {'rows': 12})
|
|
|
|
call term_wait(buf, 100)
|
|
|
|
call term_sendkeys(buf, ":DoSomething\<CR>")
|
|
|
|
call VerifyScreenDump(buf, 'Test_verbose_option_1', {})
|
|
|
|
|
|
|
|
" clean up
|
|
|
|
call StopVimInTerminal(buf)
|
|
|
|
call delete('XTest_verbose')
|
|
|
|
endfunc
|
|
|
|
|
2018-08-16 09:16:17 -07:00
|
|
|
func Test_setcmdpos()
|
|
|
|
func InsertTextAtPos(text, pos)
|
|
|
|
call assert_equal(0, setcmdpos(a:pos))
|
|
|
|
return a:text
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
" setcmdpos() with position in the middle of the command line.
|
|
|
|
call feedkeys(":\"12\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt')
|
|
|
|
call assert_equal('"1ab2', @:)
|
|
|
|
|
|
|
|
call feedkeys(":\"12\<C-R>\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt')
|
|
|
|
call assert_equal('"1b2a', @:)
|
|
|
|
|
|
|
|
" setcmdpos() with position beyond the end of the command line.
|
|
|
|
call feedkeys(":\"12\<C-B>\<C-R>=InsertTextAtPos('a', 10)\<CR>b\<CR>", 'xt')
|
|
|
|
call assert_equal('"12ab', @:)
|
|
|
|
|
|
|
|
" setcmdpos() returns 1 when not editing the command line.
|
|
|
|
call assert_equal(1, setcmdpos(3))
|
|
|
|
endfunc
|
|
|
|
|
2019-02-17 18:06:30 -07:00
|
|
|
func Test_cmdline_overstrike()
|
2019-08-19 19:13:55 -07:00
|
|
|
" Nvim: only utf8 is supported.
|
|
|
|
let encodings = ['utf8']
|
2019-02-17 18:06:30 -07:00
|
|
|
let encoding_save = &encoding
|
|
|
|
|
|
|
|
for e in encodings
|
|
|
|
exe 'set encoding=' . e
|
|
|
|
|
|
|
|
" Test overstrike in the middle of the command line.
|
|
|
|
call feedkeys(":\"01234\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt')
|
|
|
|
call assert_equal('"0ab1cd4', @:)
|
|
|
|
|
|
|
|
" Test overstrike going beyond end of command line.
|
|
|
|
call feedkeys(":\"01234\<home>\<right>\<right>ab\<right>\<insert>cdefgh\<enter>", 'xt')
|
|
|
|
call assert_equal('"0ab1cdefgh', @:)
|
|
|
|
|
|
|
|
" Test toggling insert/overstrike a few times.
|
|
|
|
call feedkeys(":\"01234\<home>\<right>ab\<right>\<insert>cd\<right>\<insert>ef\<enter>", 'xt')
|
|
|
|
call assert_equal('"ab0cd3ef4', @:)
|
|
|
|
endfor
|
|
|
|
|
2019-08-19 19:13:55 -07:00
|
|
|
" Test overstrike with multi-byte characters.
|
|
|
|
call feedkeys(":\"テキストエディタ\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt')
|
|
|
|
call assert_equal('"テabキcdエディタ', @:)
|
2019-02-17 18:06:30 -07:00
|
|
|
|
|
|
|
let &encoding = encoding_save
|
|
|
|
endfunc
|
2019-12-05 00:04:19 -07:00
|
|
|
|
|
|
|
func Test_cmdwin_feedkeys()
|
|
|
|
" This should not generate E488
|
|
|
|
call feedkeys("q:\<CR>", 'x')
|
|
|
|
endfunc
|
2020-03-22 14:40:12 -07:00
|
|
|
|
2020-11-24 23:26:52 -07:00
|
|
|
" Tests for the issues fixed in 7.4.441.
|
|
|
|
" When 'cedit' is set to Ctrl-C, opening the command window hangs Vim
|
|
|
|
func Test_cmdwin_cedit()
|
|
|
|
exe "set cedit=\<C-c>"
|
|
|
|
normal! :
|
|
|
|
call assert_equal(1, winnr('$'))
|
|
|
|
|
|
|
|
let g:cmd_wintype = ''
|
|
|
|
func CmdWinType()
|
|
|
|
let g:cmd_wintype = getcmdwintype()
|
2020-11-24 23:32:48 -07:00
|
|
|
let g:wintype = win_gettype()
|
2020-11-24 23:26:52 -07:00
|
|
|
return ''
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
call feedkeys("\<C-c>a\<C-R>=CmdWinType()\<CR>\<CR>")
|
|
|
|
echo input('')
|
|
|
|
call assert_equal('@', g:cmd_wintype)
|
2020-11-24 23:32:48 -07:00
|
|
|
call assert_equal('command', g:wintype)
|
2020-11-24 23:26:52 -07:00
|
|
|
|
|
|
|
set cedit&vim
|
|
|
|
delfunc CmdWinType
|
|
|
|
endfunc
|
|
|
|
|
2020-03-22 14:40:12 -07:00
|
|
|
func Test_buffers_lastused()
|
|
|
|
" check that buffers are sorted by time when wildmode has lastused
|
|
|
|
edit bufc " oldest
|
|
|
|
|
|
|
|
sleep 1200m
|
|
|
|
enew
|
|
|
|
edit bufa " middle
|
|
|
|
|
|
|
|
sleep 1200m
|
|
|
|
enew
|
|
|
|
edit bufb " newest
|
|
|
|
|
|
|
|
enew
|
|
|
|
|
|
|
|
call assert_equal(['bufc', 'bufa', 'bufb'],
|
|
|
|
\ getcompletion('', 'buffer'))
|
|
|
|
|
|
|
|
let save_wildmode = &wildmode
|
|
|
|
set wildmode=full:lastused
|
|
|
|
|
|
|
|
let cap = "\<c-r>=execute('let X=getcmdline()')\<cr>"
|
|
|
|
call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt')
|
|
|
|
call assert_equal('b bufb', X)
|
|
|
|
call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt')
|
|
|
|
call assert_equal('b bufa', X)
|
|
|
|
call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt')
|
|
|
|
call assert_equal('b bufc', X)
|
|
|
|
enew
|
|
|
|
|
|
|
|
sleep 1200m
|
|
|
|
edit other
|
|
|
|
call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt')
|
|
|
|
call assert_equal('b bufb', X)
|
|
|
|
call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt')
|
|
|
|
call assert_equal('b bufa', X)
|
|
|
|
call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt')
|
|
|
|
call assert_equal('b bufc', X)
|
|
|
|
enew
|
|
|
|
|
|
|
|
let &wildmode = save_wildmode
|
|
|
|
|
|
|
|
bwipeout bufa
|
|
|
|
bwipeout bufb
|
|
|
|
bwipeout bufc
|
|
|
|
endfunc
|
2020-04-28 15:57:11 -07:00
|
|
|
|
2020-10-27 20:52:02 -07:00
|
|
|
func Test_cmdlineclear_tabenter()
|
|
|
|
" See test/functional/legacy/cmdline_spec.lua
|
|
|
|
CheckScreendump
|
|
|
|
|
|
|
|
let lines =<< trim [SCRIPT]
|
|
|
|
call setline(1, range(30))
|
|
|
|
[SCRIPT]
|
|
|
|
|
|
|
|
call writefile(lines, 'XtestCmdlineClearTabenter')
|
|
|
|
let buf = RunVimInTerminal('-S XtestCmdlineClearTabenter', #{rows: 10})
|
|
|
|
call term_wait(buf, 50)
|
|
|
|
" in one tab make the command line higher with CTRL-W -
|
|
|
|
call term_sendkeys(buf, ":tabnew\<cr>\<C-w>-\<C-w>-gtgt")
|
|
|
|
call VerifyScreenDump(buf, 'Test_cmdlineclear_tabenter', {})
|
|
|
|
|
|
|
|
call StopVimInTerminal(buf)
|
|
|
|
call delete('XtestCmdlineClearTabenter')
|
|
|
|
endfunc
|
|
|
|
|
2020-04-28 15:57:11 -07:00
|
|
|
" test that ";" works to find a match at the start of the first line
|
|
|
|
func Test_zero_line_search()
|
|
|
|
new
|
|
|
|
call setline(1, ["1, pattern", "2, ", "3, pattern"])
|
|
|
|
call cursor(1,1)
|
|
|
|
0;/pattern/d
|
|
|
|
call assert_equal(["2, ", "3, pattern"], getline(1,'$'))
|
|
|
|
q!
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab
|