Skip to content

Fix infinite autocompletion loop#5130

Merged
w0rp merged 6 commits into
dense-analysis:masterfrom
letorbi:fix-infinite-autocompletion-loop
May 28, 2026
Merged

Fix infinite autocompletion loop#5130
w0rp merged 6 commits into
dense-analysis:masterfrom
letorbi:fix-infinite-autocompletion-loop

Conversation

@letorbi
Copy link
Copy Markdown
Contributor

@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
Contributor 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.

Copy link
Copy Markdown
Member

@w0rp w0rp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sensible to me.

Cheers! 🍻

@w0rp
Copy link
Copy Markdown
Member

w0rp commented May 28, 2026

There's probably some way to mitigate the test suite locking up, but if it works it'll work.

@w0rp w0rp enabled auto-merge (squash) May 28, 2026 09:58
@w0rp w0rp merged commit 399c0ff into dense-analysis:master May 28, 2026
11 checks passed
@letorbi letorbi deleted the fix-infinite-autocompletion-loop branch May 29, 2026 06:07
@letorbi
Copy link
Copy Markdown
Contributor Author

letorbi commented May 29, 2026

Great, thanks for merging :)

@letorbi
Copy link
Copy Markdown
Contributor Author

letorbi commented May 29, 2026

There's probably some way to mitigate the test suite locking up, but if it works it'll work.

The only way I could think of, would be to run the test in a separate test-suite with a timeout. Something like:

$ timeout 5 /usr/bin/vim '+Vader!*'

But maybe setting up a separate test-suite just to mitigate a problem, which is unlikely to happen, is a bit over-engineered here ;)

@letorbi letorbi restored the fix-infinite-autocompletion-loop branch May 29, 2026 07:58
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.

2 participants