Home Download Buy Blog Forum Support

[Solved]Autocomplete Help: Only show once

[Solved]Autocomplete Help: Only show once

Postby C0D312 on Wed Jan 04, 2012 10:46 pm

While I don't know if it's possible with the current API, I would like to hide my on_query_completions from the default autocomplete. For example, in my plugin Display-Functions, a list of an objects methods are added to the autocomplete. The problem is, that list remains in the autocomplete when I don't want it too. After the user picks a method, I would like that list of completions to be removed from the list. Does anyone now how I might manage this? Perhaps a workaround?

Thanks.
Last edited by C0D312 on Thu Jan 05, 2012 12:29 am, edited 1 time in total.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Autocomplete Help: Only show once

Postby quarnster on Wed Jan 04, 2012 11:17 pm

The completions provided by plugins aren't persistent.

For example try this plugin:
Code: Select all
import sublime, sublime_plugin


class Example(sublime_plugin.EventListener):
    def __init__(self):
        self.toggle = False

    def on_query_completions(self, view, prefix, locations):
        self.toggle = not self.toggle
        if self.toggle:
            return [("something", "something")]
        return []


Open up a new text file and enter:
Code: Select all
test1
test2

Then on the next line hit ctrl+space, then esc, then ctrl+space, then esc, then ctrl+space and you'll see that "something" only shows up in the completion list every other time as provided by the plugin.

If stuff shows up in the list it's either because the built in auto complete sees that word somewhere in your file or because your plugin keeps returning the same list of completions.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: Autocomplete Help: Only show once

Postby C0D312 on Thu Jan 05, 2012 12:28 am

Thanks for your help. It's definitely just a bug with my plugin. I forgot that when I manually press control+space, it still activates my plugin's on_query_completions. Additionally, there seems to be a pretty major bug in my plugin.

EDIT: I found the bug. It was pretty silly too. I forgot to clear my completion list at the end of on_query_completions. Oops :?
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 6 guests

cron