Home Download Buy Blog Forum Support

on_query_completions not working properly on ST3

on_query_completions not working properly on ST3

Postby alvms on Thu Jun 13, 2013 5:09 pm

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

<Severity>CURSOR_HERE</Severity>
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:

<Severity>

</Severity>

Any ideas?

Thanks!
alvms
 
Posts: 26
Joined: Sun May 26, 2013 9:15 pm

Re: on_query_completions not working properly on ST3

Postby alvms on Mon Jun 17, 2013 2:00 pm

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:

Code: Select all
<contact></contact>


Ig there are spaces or new lines in between the opening and closing tags, the completion works properly. For example here:
Code: Select all
<contact>

</contact>


or here:
Code: Select all
<contact>   </contact>


Steps to reproduce are:
1.- create simple plugin:
Code: Select all
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
alvms
 
Posts: 26
Joined: Sun May 26, 2013 9:15 pm

Re: on_query_completions not working properly on ST3

Postby maximsch2 on Thu Jul 04, 2013 12:24 am

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 (https://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<COMPL> 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<COMPL> 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:

Code: Select all
           
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)
maximsch2
 
Posts: 5
Joined: Sun Apr 14, 2013 10:02 pm


Return to Plugin Development

Who is online

Users browsing this forum: TWSH and 7 guests