mirror of
https://github.com/dense-analysis/ale.git
synced 2026-07-30 20:02:51 +08:00
Fix infinite autocompletion loop (#5130)
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
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
* 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
This commit is contained in:
@@ -764,6 +764,9 @@ function! s:OnReady(linter, lsp_details) abort
|
||||
let l:id = a:lsp_details.connection_id
|
||||
|
||||
if !ale#lsp#HasCapability(l:id, 'completion')
|
||||
" Return at least an empty result to avoid OmniFunc timeout
|
||||
call ale#completion#Show([])
|
||||
|
||||
return
|
||||
endif
|
||||
|
||||
@@ -945,9 +948,18 @@ function! ale#completion#OmniFunc(findstart, base) abort
|
||||
else
|
||||
let l:result = ale#completion#GetCompletionResult()
|
||||
|
||||
let l:timeout = get(g:, 'ale_completion_timeout', 3)
|
||||
let l:timeout_start = reltime()
|
||||
|
||||
while l:result is v:null && !complete_check()
|
||||
sleep 2ms
|
||||
let l:result = ale#completion#GetCompletionResult()
|
||||
|
||||
if reltimefloat(reltime(l:timeout_start)) > l:timeout
|
||||
" no-custom-checks
|
||||
echoerr 'no result within timeout (' . l:timeout . 's)'
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
|
||||
return l:result isnot v:null ? l:result : []
|
||||
|
||||
Reference in New Issue
Block a user