Sublime Forum

Autocomplete not working on XML syntax files

#1

Steps to reproduce:
1 - create a new xml file with contents
2 - make sure it has XML syntax
3 - Write a new plugin: test.py
import sublime, sublime_plugin

class GoogleAutocomplete(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
return ((“test”,“test” ), (“test2”, “test”)])

4 - reload sublime
5 - enable logging by running “sublime.log_commands(True)” in the console
6 - go to xml document, place the cursor in between the two tags and press control+space
7 - select any of the options
8 - Instead of getting test you will be getting:

9 - Open the console and watch the following entry: command: insert_snippet {"contents": "\n $0\n"}

There is a bug in Sublime that when on XML syntax, code completion does not work since the selected competion is replaced by “\n $0\n”

Interesting enough if the tags has any character in between, for example an space: " " then the completion works and you get "test " and the log shows:
command: auto_complete
command: commit_completion

So it seems like a snippet completion is trigered on the return of the on_modified function instead of actually, running the completion.

please help/fix

0 Likes

#2

More interesting details. The behaviour described happens when you use the keyboard and press enter to select an completion. If you use the mouse instead, the completion is correct (except if you click on the first option where no completion is done at all ¿?¿?)

0 Likes