-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"null" completion sources causes other sources to update slowly #1506
Comments
This is intentional—completion sources are only called after that delay, so if there is any source that doesn't have an active, synchronously-reusable result, the completions will only update, on typing, after the delay has elapsed. Before that, the library does not yet know what the set of current completions should look like. |
Do we have any workarounds except of setting The only alternative to the "null-sources" that come to mind is returning |
This reproduction is a more realistic representation of our issue. The "aaaaa" completions are always slow, due to the presence of the "bbbb" completions. It sounds like from your response that setting |
Yes, sounds like you want to set that lower if the 100ms delay bothers you. There's a trade-off between querying the completion sources very often, during fast typing, and delaying completions. The default is intended to be pretty fast while still 'chunking' quickly typed pieces of text together. Doing a thing where the completion dialog is populated bit-by-bit as the sources complete is problematic, since the list will jump around unpredictably and users are likely to accidentally confirm an option they didn't intend to, when other options pop in right when they press enter. |
Describe the issue
We have multiple completion sources, some of which only apply in specific circumstances. When they don't apply, they simple return
null
.This causes all other completion sources, even those sources that provides a
validFor
property, to be "out-of-date" for at leastactivateOnTypingDelay
ms on every keypress. If no "null-sources" are present, the remaining sources work as you'd expect based on thevalidFor
and immediately updates. The same behaviour also occurs if at least one source doesn't specify avalidFor
which is required when settingfilter: false
.This means that after every keypress there's a
activateOnTypingDelay
ms delay where if you press enter, a newline is inserted rather than the autocompletion entry.Possible this behaviour was introduced with codemirror/autocomplete@5e97bd6
We could work around this by setting
activateOnTypingDelay: 0
, but the default seems like the sensible option. In the reproduction link I've uppedactivateOnTypingDelay
to500
, but it does occur with the default100
as well.Browser and platform
No response
Reproduction link
https://codemirror.net/try/#c=aW1wb3J0IHsgbWluaW1hbFNldHVwIH0gZnJvbSAiY29kZW1pcnJvciIKaW1wb3J0IHsKICBhdXRvY29tcGxldGlvbiwKICBjb21wbGV0ZUZyb21MaXN0Cn0gZnJvbSAnQGNvZGVt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bWluaW1hbFNldHVwLAogICAgYXV0b2NvbXBsZXRlRXh0ZW5zaW9uCiAgXSwKICBwYXJlbnQ6IGRvY3VtZW50LmJvZHkKfSkK
The text was updated successfully, but these errors were encountered: