Sublime Forum

[Solved]Autocomplete Help: Only show once

#1

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.

0 Likes

#2

The completions provided by plugins aren’t persistent.

For example try this plugin:

[code]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 ][/code]

Open up a new text file and enter:

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.

0 Likes

#3

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 :confused:

0 Likes