-
Notifications
You must be signed in to change notification settings - Fork 41
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
[ST4] Cancel pending completion future when one of the items in auto_complete_triggers matches #3796
Comments
It seems to me like ST re-triggers the Either that or behavior differs with and without the That said, even if fixed, that doesn't help the case when the initial request is slow (because of being very unspecific) and user expects the second request to trigger immediately on typing |
A small plugin for testing: import sublime_plugin
from typing import List
from sublime import AutoCompleteFlags, CompletionItem, CompletionList, set_timeout
class CompletionListener(sublime_plugin.ViewEventListener):
def on_query_completions(self, prefix, locations):
print('on_query_completions, prefix: {}'.format(prefix))
if prefix in ['a', 'aa']:
return create_delayed_completions(['aaa'], 3000)
elif prefix == '':
return create_delayed_completions(['fast'], 1)
def create_delayed_completions(completions: List[str], delay: int) -> CompletionList:
completion_list = CompletionList()
flags = AutoCompleteFlags.INHIBIT_WORD_COMPLETIONS | AutoCompleteFlags.INHIBIT_EXPLICIT_COMPLETIONS
# flags |= AutoCompleteFlags.DYNAMIC_COMPLETIONS
set_timeout(lambda: completion_list.set_completions(completions, flags=flags), delay)
return completion_list Reproduction
Expected: The completions show up immediately after the Actual: The completions requested when typing the first Since completions requested for Ideally the plugin code would also be notified when the completion request is canceled but it's probably not strictly necessary. |
I've also left out disabled line that sets the Reproduction
Expected: the Actual: After typing |
Fixed in build 4161. |
I think this change has unintended side effect. When I type The expected behavior is that ST will re-trigger |
Problem description
When a plugin takes a long time to prepare results for
on_query_completions
using thesublime.CompletionList
future, it can be the case that the user has finished typing the identifier. The user then types some sort ofpunctuation.accessor
and wants to know the properties/methods of that identifier.However, ST ignores this event and instead presents the completion results from when the user started typing the first character of the identifier.
Preferred solution
When one of the items in
view.settings().get("auto_complete_triggers")
(could be a"selector"
) matches the position to the left of the caret, cancel the inflight future, and re-do theon_query_completions
callback.Alternatives
N/A
Additional Information
In the above GIF, you can see me typing s.. The on_query_completions is called for the
s
character. After the plugin is done computing the completions, we are too late in presenting the completions. The user is already wanting to see the methods of thes
String.In this GIF, you can see me typing .. The on_query_completions is called because
.
matches one of the items in"auto_complete_triggers"
. This provides the user with the desired properties/methods.The text was updated successfully, but these errors were encountered: