I’ve been using the All Auto Complete package for a while and I finally noticed that it limits you to 20 views before it stops looking. That is problematic for me, so I decided to write my own which (1) searches the buffers in order of last access, and (2) tries to be more efficient about the whole thing.
Meanwhile, there was all this code in all autocomplete to deal with a nasty bug with Sublime’s view.extract_completions method, but I thought, Naaa, that can’t be right!. But sure enough, there appears to be quite a nasty issue.
And the issue is, In some file types (e.g., syntax setting) the extract_completions code just plain old misses some matches or returns matches minus the last character.
Here’s an example. I have the following line in the middle of one of my coffeescript files:
vm.becomeUserAllowed = @UserService.current_user.isAdmin && @UserService.current_user.id != @user.id
When I run the following code in coffee script syntax:
view.extract_completions("becom")
I get
>>> window.active_view().extract_completions("becom")
['becomeUser', 'becomeUse']
the ‘becomeUser’ function exists later in the file. So it found that, but I am not sure why it also found ‘becomeUse’ because that doesn’t exist by itself anywhere in the file. But why did it miss ‘becomeUserAllowed’?
Moving along, now if I change the syntax of the view to JavaScript (which messes up the look of the file, obviously) and perform the same call to extract completions, I get this instead:
>>> window.active_view().extract_completions("becom")
['becomeUser', 'becomeUserAllowed']
This is exactly the right answer and the only difference, of course, is the syntax.
I am hoping this will be considered a bug and just fixed? The work-around is pretty nasty and involves doing a find myself, just like the All AutoComplete plugin does (although … it seems to only deal with the missing one character and not the entirely missing words itself).
Here’s some more information that boggles my mind:
- plain syntax also doesn’t work
- neither does Pascal
- or Java
In fact, so far, the only one that seems to work (ironically the one I first tested) is JavaScript!!
Wait, no, in addition to JavaScript, the following also work:
- C++
- C
- C#
- Go
- Objective-C
- … probably more
OK - I am officially w/out a clue on this one.
Any thoughts?