Home Download Buy Blog Forum Support

Really confused by on_query_completions

Really confused by on_query_completions

Postby dskinner on Sun Dec 02, 2012 5:14 am

First off, want I want to do is provide autocompletions for android xml layout files. Now that's out of the way, I'm simply confused by `on_query_completions` from `EventListener`.

Foregoing xml related stuff, I have a function that builds a dict containing related lookup material. For tag completion, I call `myDict.keys()` and return that list but nothing shows up. This is just working with dumb auto-completion where it makes the suggestion regardless of context.

If I have the following

print "searching for ", prefix
keys = self.lookup.keys()
print type(keys), keys
return keys

I can see the prefix message, I see that `keys` is a list, I see all the possible values, but nothing is suggested that's contained within the list. If i replace the return statement with

return ["chicken", "soup"]

Then suddenly both "chicken" and "soup" are available. If I hard code values from `keys` in the return, they show up as well. If I cast keys with `list(keys)` out of paranoia, it doesn't help. If I trim the list down to `keys[:3]`, those three items don't show up.

This is mind boggling for something that seems as though it should be so simple. Tips? Suggestions?

Since I have your attention as well, would it be appropriate to use a config key like:

"auto_complete_triggers": [ {"selector": "text.xml", "characters": "<"} ]

to provide completions on "<" and ":" where perhaps `on_query_context` could return `True` when encountering such?

Thanks
dskinner
 
Posts: 9
Joined: Sat Nov 17, 2012 4:34 am

Re: Really confused by on_query_completions

Postby dskinner on Sun Dec 02, 2012 5:29 am

bleh, a closer look at some examples shows a list of 2-valued tuples being returned, not a list of strings. I suppose it's confusing considering a hard coded list of strings works for autocomplete but seemingly somehow my list wasn't returning anything.
dskinner
 
Posts: 9
Joined: Sat Nov 17, 2012 4:34 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 10 guests