Files
ale/test/completion/test_omnifunc_completion.vader
T
Torben 399c0ffd64
CI / Build (push) Has been cancelled
CI / Neovim 0.10 Windows (push) Has been cancelled
CI / Neovim 0.12 Windows (push) Has been cancelled
CI / Vim 8.2 Windows (push) Has been cancelled
CI / Vim 9.2 Windows (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Lua (push) Has been cancelled
CI / Neovim 0.10 Linux (push) Has been cancelled
CI / Neovim 0.12 Linux (push) Has been cancelled
CI / Vim 8.2 Linux (push) Has been cancelled
CI / Vim 9.2 Linux (push) Has been cancelled
Fix infinite autocompletion loop (#5130)
* Check for timeout while waiting for language server result
* Return empty result if language server has no completion capabilities
* Add test for OmniFunc timeout
* Add documentation for timeout option
2026-05-28 10:00:09 +00:00

68 lines
1.8 KiB
Plaintext

Before:
unlet! b:ale_completion_info
unlet! b:ale_completion_result
let b:lsp_started = 0
runtime autoload/ale/lsp_linter.vim
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
return b:lsp_started
endfunction
function! SetCompletionResult(...) abort
let b:ale_completion_result = ['foo']
endfunction
function! SetCompletionResponse(...) abort
let b:ale_completion_result = ['foo']
endfunction
After:
unlet! b:ale_completion_info
unlet! b:ale_completion_result
unlet! b:lsp_started
delfunction SetCompletionResult
delfunction SetCompletionResponse
runtime autoload/ale/lsp_linter.vim
call ale#linter#Reset()
Given typescript():
let abc = y.
let foo = ab
let foo = (ab)
Execute(-3 should be returned when completion results cannot be requested):
AssertEqual -3, ale#completion#OmniFunc(1, '')
Execute(The start position should be returned when results can be requested):
let b:lsp_started = 1
call setpos('.', [bufnr(''), 3, 14, 0])
AssertEqual 11, ale#completion#OmniFunc(1, '')
Execute(The omnifunc function should return async results):
" Neovim struggles at running these tests.
if !has('nvim')
call timer_start(0, function('SetCompletionResult'))
AssertEqual ['foo'], ale#completion#OmniFunc(0, '')
endif
Execute(The omnifunc function should parse and return async responses):
if !has('nvim')
call timer_start(0, function('SetCompletionResponse'))
AssertEqual ['foo'], ale#completion#OmniFunc(0, '')
endif
Execute (The omnifunc function should timeout with an error, if no result is returned):
" WARNING: This will lock the whole test-suite, if the timeout does not work!
let g:ale_completion_timeout = 0.2
AssertThrows call ale#completion#OmniFunc(0, '')
AssertEqual 'Vim(echoerr):no result within timeout (0.2s)', g:vader_exception