Sublime Forum

on_query_completions not working properly on ST3

#1

Hi,

Im porting a plugin to ST3 and on_query_completions stopped working properly. So instead of adding the value returned by on_query_completions function, it is adding an empty line. An example

CURSOR_HERE
hit completion short cut,
pick on option
print the array returned by on_query_completions before returning:
(‘1.0\tValue’, ‘1.0’), (‘2.0\tValue’, ‘2.0’), (‘3.0\tValue’, ‘3.0’), (‘4.0\tValue’, ‘4.0’), (‘5.0\tValue’, ‘5.0’)]
and then, the result is:

Any ideas?

Thanks!

0 Likes

#2

I found out that this bug only occurs when dealing with XML files and under the following circumstances:

So it fails to complete when cursor is placed right in between an opening and closing tags with no spaces in between like:

<contact></contact>

Ig there are spaces or new lines in between the opening and closing tags, the completion works properly. For example here:

[code]

[/code]

or here:

<contact>	</contact>

Steps to reproduce are:
1.- create simple plugin:

import sublime import sublime_plugin class RuleCompletions(sublime_plugin.EventListener): def on_query_completions(self, view, prefix, locations): print(1) return ('1.0\tValue', '1.0'), ('2.0\tValue', '2.0'), ('3.0\tValue', '3.0'), ('4.0\tValue', '4.0'), ('5.0\tValue', '5.0')]
2.- Create simple XML file with XML syntax and press control space in between XML tags

Any idea why or how to fix it?

Thanks,
A

0 Likes

#3

Another bug report about on_query_completions, thought I’d put it here in case there will be some fixing going on:

I am developing an IPython Notebook plugin (github.com/maximsch2/SublimeIPythonNotebook) and having problems with completions (among a lot of other things). So IPython can complete both Python code and directories and I want to support. If I am completing code like this:
numpy.linalg.e using completion list like this: (numpy.linalg.eig, numpy.linalg.eigval, …)], then it works correctly by replacing “e” with last word from the selected completion (completion is separated by dots),
but if I am trying to complete directory:
/home/max/bu using completion list like this: (/home/max/bugaga, /home/max/bugaga2, …)], then after I select completion I get: “/home/max//home/max/bugaga”, so there was no “last word extraction” process there. I wonder if this is somehow connected to that XML completion problem and if there is a way to control it. I am currently forced to use a hack like this:

def on_completion():
...
  def get_last_word(s): # needed for file/directory completion
      if s.endswith("/"):
          s = s:-1]
      res = s.split("/")-1]
      return res

  return ((s + "\t (IPython)", get_last_word(s)) for s in compl], sublime.INHIBIT_EXPLICIT_COMPLETIONS | sublime.INHIBIT_WORD_COMPLETIONS)
0 Likes