mirror of
https://github.com/vim/vim.git
synced 2025-10-26 09:14:23 -04:00
patch 9.1.1672: completion: cannot add timeouts for 'cpt' sources
Problem: completion: cannot add timeouts for 'cpt' sources
(Evgeni Chasnovski)
Solution: Add the 'autocompletetimeout' and 'completetimeout' options
(Girish Palya)
fixes: #17908
closes: #17967
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
f66674cf42
commit
69a337edc1
@@ -5460,6 +5460,68 @@ func Test_omni_start_invalid_col()
|
||||
set omnifunc& complete&
|
||||
endfunc
|
||||
|
||||
func Test_completetimeout_autocompletetimeout()
|
||||
func OmniFunc(findstart, base)
|
||||
if a:findstart
|
||||
return 1
|
||||
else
|
||||
return ['fooOmni']
|
||||
endif
|
||||
endfunc
|
||||
|
||||
set omnifunc=OmniFunc
|
||||
call test_override("char_avail", 1)
|
||||
inoremap <F2> <Cmd>let b:matches = complete_info(["matches"]).matches<CR>
|
||||
|
||||
call setline(1, ['foobar', 'foobarbaz'])
|
||||
new
|
||||
call setline(1, ['foo', 'foobaz', ''])
|
||||
set complete=.,o,w
|
||||
call feedkeys("G", 'xt!')
|
||||
|
||||
set autocomplete
|
||||
for tt in [1, 80, 1000, -1, 0]
|
||||
exec $'set autocompletetimeout={tt}'
|
||||
call feedkeys("\<Esc>Sf\<F2>\<Esc>0", 'xt!')
|
||||
call assert_equal(['foobaz', 'foo', 'fooOmni', 'foobar', 'foobarbaz'], b:matches->mapnew('v:val.word'))
|
||||
endfor
|
||||
set autocomplete&
|
||||
|
||||
for tt in [80, 1000, -1, 0]
|
||||
exec $'set completetimeout={tt}'
|
||||
call feedkeys("\<Esc>Sf\<C-N>\<F2>\<Esc>0", 'xt!')
|
||||
call assert_equal(['foo', 'foobaz', 'fooOmni', 'foobar', 'foobarbaz'], b:matches->mapnew('v:val.word'))
|
||||
endfor
|
||||
|
||||
" Clock does not have fine granularity, so checking 'elapsed time' is only
|
||||
" approximate. We can only test that some type of timeout is enforced.
|
||||
call feedkeys("\<Esc>", 'xt!')
|
||||
call setline(1, map(range(60000), '"foo" . v:val'))
|
||||
set completetimeout=1
|
||||
call feedkeys("Gof\<C-N>\<F2>\<Esc>0", 'xt!')
|
||||
let match_count = len(b:matches->mapnew('v:val.word'))
|
||||
call assert_true(match_count < 2000)
|
||||
|
||||
set completetimeout=1000
|
||||
call feedkeys("\<Esc>Sf\<C-N>\<F2>\<Esc>0", 'xt!')
|
||||
let match_count = len(b:matches->mapnew('v:val.word'))
|
||||
call assert_true(match_count > 2000)
|
||||
|
||||
set autocomplete
|
||||
set autocompletetimeout=81
|
||||
call feedkeys("\<Esc>Sf\<F2>\<Esc>0", 'xt!')
|
||||
let match_count = len(b:matches->mapnew('v:val.word'))
|
||||
call assert_true(match_count < 50000)
|
||||
|
||||
call feedkeys("\<Esc>", 'xt!')
|
||||
set complete& omnifunc& autocomplete& autocompletetimeout& completetimeout&
|
||||
bwipe!
|
||||
%d
|
||||
call test_override("char_avail", 0)
|
||||
iunmap <F2>
|
||||
delfunc OmniFunc
|
||||
endfunc
|
||||
|
||||
func Test_autocompletedelay()
|
||||
CheckScreendump
|
||||
|
||||
|
||||
Reference in New Issue
Block a user