Sublime Forum

Autocomplete API - Allow async update of autocomplete items

#1

A lot of autocomplete packages rely on external services (Jedi, TernJS, etc.). It would be very useful to have an API in sublime that allows for a later (async) update to an autocomplete list that is already shown. Most packages get around this by having to run a hide_auto_complete command followed by auto_complete in order to update the list, thereby regenerating the whole list.

For example, here’s one way of going about it:

in

on_query_completions(...) 
   # make async call
   # generate a unique id for this session
   return my_id, [], flags

An on_autocomplete_hide event in the event listener would be really useful. So that if in the async call the autocomplete is already hidden, we don’t need waste effort. Other functions like is_autocomplete_active would be useful.

in the async callback:

# make my autocomplete request
view.run_command("update_completions", {"id" : my_id, "completions" : completions})

sublime would update the original completions associated with my_id (which was []) with your new ones. so you wouldn’t interfere with other packages completions. more generally, one could pass in a few completions already, and add more ones later on, if update them if the state of the application changes. snippets/word completions could be shown immediately and then the rest would be sublimely injected. :stuck_out_tongue_winking_eye:

this would really improve that smooth feel (that i love about sublime) in some cases. e.g. in Anaconda, the autocomplete flickers sometimes.

5 Likes

#2

this has also been requested at

0 Likes