Skip to content

Fix infinite autocompletion loop#5130

Open
letorbi wants to merge 6 commits into
dense-analysis:masterfrom
letorbi:fix-infinite-autocompletion-loop
Open

Fix infinite autocompletion loop#5130
letorbi wants to merge 6 commits into
dense-analysis:masterfrom
letorbi:fix-infinite-autocompletion-loop

Conversation

@letorbi
Copy link
Copy Markdown

@letorbi letorbi commented May 19, 2026

I stumbled upon an infinite loop while using "pure" omnicompletion with ALE's omnifunction and Vim's native autocompletion:

set completeopt=menu,menuone,noselect,noinsert
set autocomplete
autocmd FileType * setlocal omnifunc=ale#completion#OmniFunc

Apparently ale#completion#OmniFunc does not ever return, if the language server has no completion capabilities. I was able to track the cause down to the while-loop, which waits for the server result. This PR breaks the infinite-loop by introducing a timeout check in the while-loop. The timeout is 3 seconds by default, but can be configured via g:ale_completion_timeout, which takes a float value that is interpreted as seconds.

Additionally, I was able to fix the underlying cause by returning an empty result, if the language server does not have completion capabilities. This fixes the problem, but IMHO the timeout should still be included in order to prevent locks due to other reasons.

A test has also been added, but I am not sure whether it should really be included in the test suite, because it might lock the whole suite, if the timeout does not work as expected.

@letorbi letorbi requested a review from w0rp as a code owner May 19, 2026 16:20
@letorbi
Copy link
Copy Markdown
Author

letorbi commented May 20, 2026

Sorry for adding additional commits, despite the PR was not marked as a draft. I am done now and the PR is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant