completion: 'autocompletedelay' blocks the main loop and drops autocommands#20598
completion: 'autocompletedelay' blocks the main loop and drops autocommands#20598h-east wants to merge 1 commit into
Conversation
ab8652f to
170fc9e
Compare
Good catch — you're right. In the current PoC the input-wait timeout is |
170fc9e to
ffb0c69
Compare
|
@girishji as the owner of the The PR makes Two things I'd especially like your opinion on:
Thanks! |
|
@h-east can you capture a screencast to show how cursor behavior is different with your changes? |
|
Ok, a stupid question. |
|
@girishji |
|
@Mrpaoo |
|
While investigating, I found that master has a pre-existing bug: the ruler |
ab18791 to
7bb7862
Compare
|
The CI failures came down to two separate things, and I've updated the 1. A timing issue in the test itself. 2. The ruler column shown while the completion popup is up. On (2): the dumps that are supposed to check the state during the delay were After that, the ruler shows the cursor column in all the popup dumps except I'd keep this PR focused on the async change and fix that as a separate patch — @girishji does that sound reasonable to you? |
|
Looks good, but there are many moving parts. I suggest you use this delay feature in your workflow for a few days to make sure there are no issues. Also, I think you should prioritize fixing Test_autocompletedelay_6 (Backspace) and Test_fuzzy_autocompletedelay_3 as part of this commit. |
7bb7862 to
629ac09
Compare
|
Squashed into a single commit and updated the commit message and PR description to reflect the latest changes.
The above-mentioned fix has also been incorporated into this PR. For further details regarding this change, please see the commit message or PR description. |
629ac09 to
1ae6b12
Compare
1ae6b12 to
f85b659
Compare
|
While testing with $ vim --clean +"set ac acl=500" +"call setline(1, ['foobar foobaz foobiz', ''])" +"call feedkeys('GCfoob', 't')"
It comes from Two ways to look at it: re-arming is consistent (every leader change is One possibility would be to show the popup immediately when it is already (Added:) |
I will fix it to follow the master's behavior. --> Done. |
f85b659 to
d880b11
Compare
|
@girishji @chrisbra A heads-up on the ruler fix we agreed to include here. I have split it out into a separate, master-based PR: #20626. The reason is that it turned out to be a pre-existing bug that is independent of So this still addresses the ruler problem you asked about - just in a dedicated @chrisbra - the merge order matters here: #20626 should go in first (I've also |
d880b11 to
30e7b8e
Compare
…mmands
Problem: With a non-zero 'autocompletedelay', Insert-mode autocommands
(TextChangedI, TextChangedP, CursorMovedI) are delayed, and
while typing faster than the delay they are dropped entirely,
because the delay blocks the main loop.
Solution: Make 'autocompletedelay' non-blocking: instead of busy-waiting
before showing the popup menu, defer it with an input-wait
timeout (K_COMPLETE_DELAY) modeled on CursorHoldI, so typing
stays responsive and the Insert-mode autocommands fire normally.
The delay timer coexists with 'updatetime': the main loop waits for the
sooner of the two and triggers the event whose deadline was reached, so
'autocompletedelay' no longer shadows CursorHold timing. Changing the
completion leader, for example with Backspace, updates the visible popup
immediately like a zero delay; only the first popup is deferred.
Update the 'autocompletedelay' screendumps for the non-blocking display.
One test opened the menu with CTRL-N right after the delay expired and
could race with the deferred popup, so it now waits a little longer than
the delay before sending the key.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30e7b8e to
04fb3d8
Compare

The delay timer coexists with 'updatetime': the main loop waits for the
sooner of the two and triggers the event whose deadline was reached, so
'autocompletedelay' no longer shadows CursorHold timing. Changing the
completion leader, for example with Backspace, updates the visible popup
immediately like a zero delay; only the first popup is deferred.
Update the 'autocompletedelay' screendumps for the non-blocking display.
One test opened the menu with CTRL-N right after the delay expired and
could race with the deferred popup, so it now waits a little longer than
the delay before sending the key.
fixes #20591